-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.py
executable file
·74 lines (64 loc) · 2.8 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import getopt
import traceback
import os
import platform
from pathlib import PurePath
import PySide6
import sys
from PySide6.QtWidgets import QApplication
from gui.RaidionicsMainWindow import RaidionicsMainWindow
import logging
# macOS relevant
os.environ['LC_CTYPE'] = "en_US.UTF-8"
os.environ['LANG'] = "en_US.UTF-8"
# macOS Big Sur related: https://stackoverflow.com/questions/64818879/is-there-any-solution-regarding-to-pyqt-library-doesnt-work-in-mac-os-big-sur/64856281
os.environ['QT_MAC_WANTS_LAYER'] = '1'
# relevant for PySide, Qt stuff. See issue here: https://www.programmersought.com/article/8605863159/
dirname = os.path.dirname(PySide6.__file__)
plugin_path = os.path.join(dirname, 'plugins', 'platforms')
os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = plugin_path
def main(argv):
gui_usage = 1
try:
opts, args = getopt.getopt(argv, "hg:", ["gui=1"])
except getopt.GetoptError:
print('main.py')
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print('main.py')
sys.exit()
# elif opt in ("-g", "--use_gui"):
# gui_usage = int(arg)
try:
from utils.software_config import SoftwareConfigResources
# logging.basicConfig(filename=SoftwareConfigResources.getInstance().get_session_log_filename(), filemode='w',
# format="%(asctime)s ; %(name)s ; %(levelname)s ; %(message)s", datefmt='%d/%m/%Y %H.%M')
# logging.getLogger().setLevel(logging.DEBUG)
logger = logging.getLogger()
handler = logging.FileHandler(filename=SoftwareConfigResources.getInstance().get_session_log_filename(),
mode='w', encoding='utf-8')
handler.setFormatter(logging.Formatter(fmt="%(asctime)s ; %(name)s ; %(levelname)s ; %(message)s",
datefmt='%d/%m/%Y %H.%M'))
logger.setLevel(logging.DEBUG)
logger.addHandler(handler)
if gui_usage == 1:
app = QApplication(sys.argv)
window = RaidionicsMainWindow(application=app)
window.show()
app.exec()
#@TODO. Windows-specific stuff to check.
# # ifdef Q_OS_WIN //this is Windows specific code, not portable
# QWindowsWindowFunctions::setWindowActivationBehavior(QWindowsWindowFunctions::AlwaysActivateWindow);
# # endif
# For mac, try: window.raise()
except Exception as e:
print('Process could not proceed. Caught error: {}'.format(e.args[0]))
print('{}'.format(traceback.format_exc()))
logging.critical(traceback.format_exc())
if __name__ == "__main__":
# if platform.system() == 'Windows':
import multiprocessing as mp
mp.freeze_support()
mp.set_start_method('spawn', force=True)
main(sys.argv[1:])