-
Notifications
You must be signed in to change notification settings - Fork 7
/
main.py
55 lines (38 loc) · 1.48 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
from dls_barcode.gui.main_window import DiamondBarcodeMainWindow
import logging
import logconfig
import sys
from os.path import dirname
from sys import path
from dls_barcode.config import BarcodeConfig
from PyQt5 import QtWidgets
import argparse
from dls_barcode.version import VERSION
from dls_util.file import FileManager
path.append(dirname(path[0]))
# Required for multiprocessing to work under PyInstaller bundling in Windows
from dls_util import multiprocessing_support
# Detect if the program is running from source or has been bundled
IS_BUNDLED = getattr(sys, 'frozen', False)
if IS_BUNDLED:
DEFAULT_CONFIG_FILE = "./config.ini"
else:
DEFAULT_CONFIG_FILE = "../config.ini"
def main(config_file, version):
# Start process logger
logconfig.setup_logging()
log = logging.getLogger(".".join([__name__]))
log.info("CONFIG: " + config_file)
log.debug(version)
app = QtWidgets.QApplication(sys.argv)
config = BarcodeConfig(config_file, FileManager())
ui = DiamondBarcodeMainWindow(config, VERSION, None)
ui.set_actions_triger()
sys.exit(app.exec_())
if __name__ == '__main__':
# Multiprocessing support for PyInstaller bundling in Windows
parser = argparse.ArgumentParser()
parser.add_argument("-cf", "--config_file", type=str, default=DEFAULT_CONFIG_FILE,
help="The path of the configuration file (default=" + DEFAULT_CONFIG_FILE + ")")
args = parser.parse_args()
main(args.config_file, VERSION)