forked from dbouget/validation_metrics_computation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
45 lines (39 loc) · 1.53 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
import getopt
import traceback
import sys
import logging
import os
from raidionicsval.compute import compute
def main(argv):
config_filename = None
try:
logging.basicConfig(format="%(asctime)s ; %(name)s ; %(levelname)s ; %(message)s", datefmt='%d/%m/%Y %H.%M')
logging.getLogger().setLevel(logging.WARNING)
opts, args = getopt.getopt(argv, "h:c:v:", ["Config=", "Verbose="])
except getopt.GetoptError:
print('usage: main.py -c <configuration_filepath> (--Verbose <mode>)')
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print('main.py -c <configuration_filepath> (--Verbose <mode>)')
sys.exit()
elif opt in ("-c", "--Config"):
config_filename = arg
elif opt in ("-v", "--Verbose"):
if arg.lower() == 'debug':
logging.getLogger().setLevel(logging.DEBUG)
elif arg.lower() == 'info':
logging.getLogger().setLevel(logging.INFO)
elif arg.lower() == 'warning':
logging.getLogger().setLevel(logging.WARNING)
elif arg.lower() == 'error':
logging.getLogger().setLevel(logging.ERROR)
if not config_filename or not os.path.exists(config_filename):
print('usage: main.py -c <config_filepath> (--Verbose <mode>)')
sys.exit()
try:
compute(config_filename=config_filename)
except Exception as e:
logging.error('{}'.format(traceback.format_exc()))
if __name__ == "__main__":
main(sys.argv[1:])