-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
52 lines (45 loc) · 1.18 KB
/
main.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
import sys, os
from lib.utilities import trace, bootstrap, resetSettings
from app import TinyMPCApp
from mainwindow import AppWindow
import argparse
def run():
def parseCommandLine(info):
parser = argparse.ArgumentParser(info.appname)
parser.add_argument('-V', '--version', action='store_true', default=False)
parser.add_argument('-i', '--info', action='store_true', default=False)
parser.add_argument('-r', '--reset', action='store_true', default=False)
return parser.parse_args(sys.argv[1:])
trace(os.uname(), level='info')
try:
mainWindow = None
bts = bootstrap()
trace(f'bootstrap: {bts}', level='info')
# handle command-line arguments
cli = parseCommandLine(bts)
if cli.reset:
resetSettings()
return 0
if cli.version:
print(bts.version)
return 0
if cli.info:
print(*[
f'{k}={v}'
for k,v in sorted(bts._asdict().items(), key=lambda x:x[0])
],
sep='\n')
return 0
# start app
app = TinyMPCApp(sys.argv)
mainWindow = AppWindow(app)
mainWindow.show()
mainWindow.postShow()
return app.exec()
except Exception as x:
trace(f'ERROR: {x}', level='error')
raise x
finally:
pass
if __name__ == '__main__':
sys.exit(run())