-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.py
48 lines (42 loc) · 1.43 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
#!/usr/bin/env python3
"""Start up script for the Start-Menu-Helper program."""
import argparse
import logging
import os
import pathlib
import wx
from library import constants, gui
if __name__ == "__main__":
if not os.path.exists(constants.DEFAULT_CONFIGURATION_PATH):
os.mkdir(constants.DEFAULT_CONFIGURATION_PATH)
logging.basicConfig(
level=logging.INFO,
filename=constants.LOG_FILE_PATH,
filemode="a",
format="%(asctime)s - %(levelname)s - %(message)s"
)
argument_parser = argparse.ArgumentParser()
argument_parser.add_argument(
"-b",
"--start-in-background",
action="store_true",
help="Start the program in the background with the previous configuration"
)
argument_parser.add_argument(
"-c",
"--config-directory",
action="store",
help="Specify an alternative directory where the configuration files are located "
f"(Default is \"{constants.DEFAULT_CONFIGURATION_PATH}\")"
)
arguments = argument_parser.parse_args()
app = wx.App()
configuration_directory = constants.DEFAULT_CONFIGURATION_PATH
if arguments.config_directory:
configuration_directory = arguments.config_directory
main_frame = gui.MainFrame(pathlib.Path(configuration_directory))
if arguments.start_in_background:
main_frame.start_scanning()
else:
main_frame.Show()
app.MainLoop()