forked from LanceFiondella/C-SFRAT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
68 lines (51 loc) · 2.16 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
#!/usr/bin/python
"""File that is run to begin the Covariate Tool application.
This file is run using the command line, with optional arguments.
These arguments allow the application to be run in verbose mode,
which provides additional information on calculations, or in debug mode,
which prints informations about application state and events that
a typical user would not need to worry about.
Typical usage example (on command line):
python main.py
python main.py -v
python main.py -d
The first line will run the application in the default mode,
with no additional information printed to the command line.
The second line will run the application in verbose mode.
The third line will run the application in debug mode.
"""
import argparse # to handle command line arguments
import logging as log # to handle debug output
import sys
from PyQt5.QtWidgets import QApplication # for UI
from ui.mainWindow import MainWindow
def main(debug):
"""
Begins running application and creates instance of MainWindow class.
Args
debug: Boolean indicating if debug mode is active or not
"""
log.info("Starting C-SFRAT.")
app = QApplication(sys.argv)
mainWindow = MainWindow(debug)
sys.exit(app.exec_())
if __name__ == "__main__":
# command line arguments
parser = argparse.ArgumentParser(description='C-SFRAT')
parser.add_argument("-v", '--verbose', action='store_true')
parser.add_argument('-d', '--debug', action='store_true')
args = parser.parse_args()
debug = False
if args.debug:
debug = True
log.basicConfig(format="%(levelname)s: %(message)s", level=log.DEBUG)
log.debug("In DEBUG mode.")
elif args.verbose:
# if using verbose output set logging to display level and message
# print anything level debug or higher
log.basicConfig(format="%(levelname)s: %(message)s", level=log.INFO)
log.info("Using verbose output.")
else:
# if not using verbose output only print errors and warnings
log.basicConfig(format="%(levelname)s: %(message)s")
main(debug)