-
Notifications
You must be signed in to change notification settings - Fork 8
/
tasks.py
executable file
·487 lines (409 loc) · 15.2 KB
/
tasks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
############################################################
# -*- coding: utf-8 -*-
#
# # # # # # #
# ## ## # ## # #
# # # # # # # # # # #
# # ## # ## ## ######
# # # # # # #
#
# Python-based Tool for interaction with the 10micron mounts
# GUI with PyQT5 for python
#
# written in python3, (c) 2019-2023 by mworion
# Licence APL2.0
#
###########################################################
from invoke import task
from PIL import Image
import glob
import time
import os
import zipapp
import zipfile
rn = ''
#
# defining all necessary virtual client login for building over all platforms
#
client = {
'ubuntu-20': {
'user': '[email protected]',
'work': '/home/mw/test',
'scp': '[email protected]:/home/mw/test',
},
'ubuntu-22': {
'user': '[email protected]',
'work': '/home/mw/test',
'scp': '[email protected]:/home/mw/test',
},
'ubuntuRig': {
'user': '[email protected]',
'work': '/home/mw/test',
'scp': '[email protected]:/home/mw/test',
},
'win10-32-old': {
'user': '[email protected]',
'work': 'test',
'scp': '[email protected]:/Users/mw/test',
},
'win10-64-old': {
'user': '[email protected]',
'work': 'test',
'scp': '[email protected]:/Users/mw/test',
},
'win10-32': {
'user': '[email protected]',
'work': 'test',
'scp': '[email protected]:/Users/mw/test',
},
'win10-64': {
'user': '[email protected]',
'work': 'test',
'scp': '[email protected]:/Users/mw/test',
},
'win11': {
'user': '[email protected]',
'work': 'test',
'scp': '[email protected]:/Users/mw/test',
},
'macBigsur': {
'user': '[email protected]',
'work': 'test',
'scp': '[email protected]:/Users/mw/test',
},
'macMonterey': {
'user': '[email protected]',
'work': 'test',
'scp': '[email protected]:/Users/mw/test',
},
'macVentura': {
'user': '[email protected]',
'work': 'test',
'scp': '[email protected]:/Users/mw/test',
},
}
def runMW(c, param):
c.run(param)
def printMW(param):
print(param)
@task
def log(c):
runMW(c, 'python3 logViewer.py')
@task
def clean_mw(c):
printMW('clean mountwizzard')
runMW(c, 'rm -rf .pytest_cache')
runMW(c, 'rm -rf mw4.egg-info')
runMW(c, 'find ./mw4 | grep -E "(__pycache__)" | xargs rm -rf')
printMW('clean mountwizzard finished\n')
@task
def image_res(c):
printMW('changing image resolution for docs to 150 dpi')
files = glob.glob('./doc/source/**/*.png', recursive=True)
for file in files:
print(file)
im = Image.open(file)
im.save(file, dpi=(150, 150))
printMW('changing image resolution for docs to 150 dpi finished\n')
@task
def version_doc(c):
printMW('changing the version number to setup.py')
# getting version of desired package
with open('setup.py', 'r') as setup:
text = setup.readlines()
for line in text:
if line.strip().startswith('version'):
_, number, _ = line.split("'")
# reading configuration file
with open('./doc/source/conf.py', 'r') as conf:
text = conf.readlines()
textNew = list()
print(f'version is >{number}<')
# replacing the version number
for line in text:
if line.startswith('version'):
line = f"version = '{number}'\n"
if line.startswith('release'):
line = f"release = '{number}'\n"
textNew.append(line)
# writing configuration file
with open('./doc/source/conf.py', 'w+') as conf:
conf.writelines(textNew)
printMW('changing the version number to setup.py finished\n')
@task
def update_builtins(c):
printMW('updating builtins')
runMW(c, 'cp ./work/data/de440_mw4.bsp ./mw4/resource/data/de440_mw4.bsp')
runMW(c, 'cp ./work/data/visual.txt ./mw4/resource/data/visual.txt')
runMW(c, 'cp ./work/data/finals2000A.all ./mw4/resource/data/finals2000A.all')
runMW(c, 'cp ./work/data/finals.data ./mw4/resource/data/finals.data')
runMW(c, 'cp ./work/data/CDFLeapSeconds.txt ./mw4/resource/data/CDFLeapSeconds.txt')
printMW('updating builtins finished\n')
@task
def build_resource(c):
printMW('building resources')
resourceDir = './mw4/resource/'
with c.cd(resourceDir + 'data'):
with open(resourceDir + 'data/content.txt', 'w') as f:
for file in glob.glob(resourceDir + 'data/*.*'):
t = os.stat(file).st_mtime
f.write(f'{os.path.basename(file)} {t}\n')
runMW(c, f'pyrcc5 -o {resourceDir}resources.py {resourceDir}resources.qrc')
printMW('building resources finished\n')
@task
def build_widgets(c):
printMW('building widgets')
widgetDir = './mw4/gui/widgets/'
widgets = [
'analyse', 'devicePopup', 'downloadPopup', 'hemisphere', 'image',
'keypad', 'main', 'measure', 'message', 'satellite', 'simulator',
'video', 'bigPopup',
]
for widget in widgets:
name = widgetDir + widget
runMW(c, f'python -m PyQt5.uic.pyuic -x {name}.ui -o {name}_ui.py')
printMW('building widgets finished\n')
@task()
def test_mw(c):
printMW('testing mountwizzard4')
runMW(c, 'flake8')
runMW(c, 'pytest tests/unit_tests/zLoader')
runMW(c, 'pytest tests/unit_tests/zMainApp')
runMW(c, 'pytest tests/unit_tests/zUpdate')
runMW(c, 'pytest tests/unit_tests/base')
runMW(c, 'pytest tests/unit_tests/gui/extWindows')
runMW(c, 'pytest tests/unit_tests/gui/mainWindow')
runMW(c, 'pytest tests/unit_tests/gui/mainWmixin1')
runMW(c, 'pytest tests/unit_tests/gui/mainWmixin2')
runMW(c, 'pytest tests/unit_tests/gui/mainWmixin3')
runMW(c, 'pytest tests/unit_tests/gui/utilities')
runMW(c, 'pytest tests/unit_tests/indibase')
runMW(c, 'pytest tests/unit_tests/logic/automation')
runMW(c, 'pytest tests/unit_tests/logic/camera')
runMW(c, 'pytest tests/unit_tests/logic/cover')
runMW(c, 'pytest tests/unit_tests/logic/databaseProcessing')
runMW(c, 'pytest tests/unit_tests/logic/dome')
runMW(c, 'pytest tests/unit_tests/logic/environment')
runMW(c, 'pytest tests/unit_tests/logic/filter')
runMW(c, 'pytest tests/unit_tests/logic/focuser')
runMW(c, 'pytest tests/unit_tests/logic/keypad')
runMW(c, 'pytest tests/unit_tests/logic/measure')
runMW(c, 'pytest tests/unit_tests/logic/modeldata')
runMW(c, 'pytest tests/unit_tests/logic/plateSolve')
runMW(c, 'pytest tests/unit_tests/logic/powerswitch')
runMW(c, 'pytest tests/unit_tests/logic/remote')
runMW(c, 'pytest tests/unit_tests/logic/telescope')
runMW(c, 'pytest tests/unit_tests/mountcontrol')
printMW('testing mountwizzard finished\n')
@task(pre=[])
def build_startup(c):
printMW('...make zip archive')
zipapp.create_archive('./generators/startup/startup.py',
target='./support/3.0/startup.pyz',
compressed=True,
main='startup:main')
os.chdir('./support/3.0')
with zipfile.ZipFile('startupPackage.zip', 'w') as myzip:
myzip.write('startup.pyz')
myzip.write('MountWizzard4.desktop')
myzip.write('mw4.ico')
myzip.write('mw4.png')
runMW(c, 'cp startup.pyz ../../work')
os.chdir('../../')
printMW('...copy install script to test dir')
@task(pre=[])
def pypiCleanup(c):
printMW('...clean pypi from alpha versions')
regex = '1\\.\\w*\\.\\d\\D\\d*$'
runMW(c, f'pypi-cleanup -u mworion -p mountwizzard4 -r {regex} -y')
def test_windows(c, user, work, scp):
printMW('...delete test dir')
runMW(c, f'ssh {user} "if exist {work} rd /s /q {work}"')
time.sleep(1)
printMW('...make test dir')
runMW(c, f'ssh {user} "if not exist {work} mkdir {work}"')
time.sleep(1)
with c.cd('dist'):
printMW('...copy *.tar.gz to test dir')
runMW(c, f'scp -r mountwizzard4.tar.gz {scp}')
with c.cd('support'):
runMW(c, f'scp -r ./3.0/startup.pyz {scp}')
runMW(c, f'ssh {user} "cd {work} && echo > test.run"')
runMW(c, f'ssh {user} "cd {work} && python startup.pyz --no-start"')
runMW(c, f'ssh {user} "cd {work} && python startup.pyz"')
def test_ubuntu_main(c, user, work, scp):
printMW('...delete test dir')
runMW(c, f'ssh {user} "rm -rf {work}"')
time.sleep(1)
printMW('...make test dir')
runMW(c, f'ssh {user} "mkdir {work}"')
time.sleep(1)
with c.cd('dist'):
printMW('...copy *.tar.gz to test dir')
runMW(c, f'scp -r mountwizzard4.tar.gz {scp}')
with c.cd('support'):
runMW(c, f'scp -r ./3.0/startup.pyz {scp}')
runMW(c, f'ssh {user} "cd {work} && echo > test.run"')
runMW(c, f'ssh {user} "cd {work} && python3 startup.pyz --no-start"')
runMW(c, f'ssh {user} "cd {work} && python3 startup.pyz"')
def test_mac(c, user, work, scp):
printMW('...delete test dir')
runMW(c, f'ssh {user} "rm -rf {work}"')
time.sleep(1)
printMW('...make test dir')
runMW(c, f'ssh {user} "mkdir {work}"')
time.sleep(1)
with c.cd('dist'):
printMW('...copy *.tar.gz to test dir')
runMW(c, f'scp -r mountwizzard4.tar.gz {scp}')
with c.cd('support'):
runMW(c, f'scp -r ./3.0/startup.pyz {scp}')
runMW(c, f'ssh {user} "cd {work} && echo > test.run"')
runMW(c, f'ssh {user} "cd {work} && python3 startup.pyz --no-start"')
runMW(c, f'ssh {user} "cd {work} && python3 startup.pyz"')
@task(pre=[build_startup])
def test_win1032old(c):
printMW('test windows10 32 old install')
user = client['win10-32-old']['user']
work = client['win10-32-old']['work']
scp = client['win10-32-old']['scp']
test_windows(c, user, work, scp)
printMW('test windows10 install finished\n')
@task(pre=[build_startup])
def test_win1064old(c):
printMW('test windows10 64 old install')
user = client['win10-64-old']['user']
work = client['win10-64-old']['work']
scp = client['win10-64-old']['scp']
test_windows(c, user, work, scp)
printMW('test windows10 install finished\n')
@task(pre=[build_startup])
def test_win1032(c):
printMW('test windows10 32 install')
user = client['win10-32']['user']
work = client['win10-32']['work']
scp = client['win10-32']['scp']
test_windows(c, user, work, scp)
printMW('test windows10 install finished\n')
@task(pre=[build_startup])
def test_win1064(c):
printMW('test windows10 64 install')
user = client['win10-64']['user']
work = client['win10-64']['work']
scp = client['win10-64']['scp']
test_windows(c, user, work, scp)
printMW('test windows10 install finished\n')
@task(pre=[build_startup])
def test_win11(c):
printMW('test windows11 install')
user = client['win11']['user']
work = client['win11']['work']
scp = client['win11']['scp']
test_windows(c, user, work, scp)
printMW('test windows11 install finished\n')
@task(pre=[build_startup])
def test_ubuntu_20(c):
printMW('test ubuntu install')
user = client['ubuntu-20']['user']
work = client['ubuntu-20']['work']
scp = client['ubuntu-20']['scp']
test_ubuntu_main(c, user, work, scp)
printMW('test ubuntu install finished\n')
@task(pre=[build_startup])
def test_ubuntu_22(c):
printMW('test ubuntu install')
user = client['ubuntu-22']['user']
work = client['ubuntu-22']['work']
scp = client['ubuntu-22']['scp']
test_ubuntu_main(c, user, work, scp)
printMW('test ubuntu install finished\n')
@task(pre=[build_startup])
def test_comp(c):
printMW('test ubuntu rig install')
user = client['ubuntuRig']['user']
work = client['ubuntuRig']['work']
scp = client['ubuntuRig']['scp']
test_ubuntu_main(c, user, work, scp)
printMW('test ubuntu rig install finished\n')
@task(pre=[build_startup])
def test_macBigsur(c):
printMW('test BigSur install')
user = client['macBigsur']['user']
work = client['macBigsur']['work']
scp = client['macBigsur']['scp']
test_mac(c, user, work, scp)
printMW('test BigSur install finished\n')
@task(pre=[build_startup])
def test_macMonterey(c):
printMW('test Monterey install')
user = client['macMonterey']['user']
work = client['macMonterey']['work']
scp = client['macMonterey']['scp']
test_mac(c, user, work, scp)
printMW('test Monterey install finished\n')
@task(pre=[build_startup])
def test_macVentura(c):
printMW('test Monterey install')
user = client['macVentura']['user']
work = client['macVentura']['work']
scp = client['macVentura']['scp']
test_mac(c, user, work, scp)
printMW('test Ventura install finished\n')
@task(pre=[version_doc])
def make_pdf(c):
drawio = '/Applications/draw.io.app/Contents/MacOS/draw.io'
printMW('Generate PDF for distro')
for fullFilePath in glob.glob('./doc/**/**.drawio', recursive=True):
output = fullFilePath[:-6] + 'png'
command = f'{drawio} -x -f png -o {output} {fullFilePath}'
runMW(c, command)
with c.cd('doc'):
runMW(c, 'make latexpdf')
runMW(c, 'mv ./doc/build/latex/mountwizzard4.pdf ./mw4/resource/data')
printMW('Generation finished\n')
@task(pre=[version_doc])
def make_html(c):
drawio = '/Applications/draw.io.app/Contents/MacOS/draw.io'
printMW('Generate HTML for distro')
for fullFilePath in glob.glob('./doc/**/**.drawio', recursive=True):
output = fullFilePath[:-6] + 'png'
command = f'{drawio} -x -f png -o {output} {fullFilePath}'
runMW(c, command)
with c.cd('doc'):
runMW(c, 'make html')
with c.cd('docs'):
runMW(c, 'rm -rf *')
runMW(c, 'rm -rf .nojekyll')
runMW(c, 'rm -rf .buildinfo')
with c.cd('doc/build'):
runMW(c, 'mv html/* ../../docs')
runMW(c, 'mv html/.nojekyll ../../docs')
runMW(c, 'mv html/.buildinfo ../../docs')
printMW('Generation finished\n')
@task(pre=[make_html, make_pdf, build_resource, build_widgets])
def build_mw(c):
printMW('building dist mountwizzard4')
with c.cd('.'):
runMW(c, 'rm -f dist/mountwizzard4*.tar.gz')
runMW(c, 'python setup.py sdist')
runMW(c, 'cp dist/mountwizzard4*.tar.gz '
'../MountWizzard4/dist/mountwizzard4.tar.gz')
with open('notes.txt') as f:
printMW(f.read())
printMW('building dist mountwizzard4 finished\n')
printMW('generating documentation')
@task(pre=[make_pdf, make_html])
def show_doc(c):
with c.cd('docs'):
runMW(c, 'open ./index.html')
runMW(c, 'open ./mw4/resource/data/mountwizzard4.pdf')
@task(pre=[version_doc, build_mw])
def upload_mw(c):
printMW('uploading dist mountwizzard4')
with open('notes.txt') as f:
rn = f.read()
with c.cd('./dist'):
print(f'twine upload mountwizzard4-*.tar.gz --verbose -r pypi -c "{rn}"')
runMW(c, f'twine upload mountwizzard4-*.tar.gz -r pypi -c "{rn}"')
runMW(c, 'rm notes.txt')
printMW('uploading dist mountwizzard4 finished\n')