-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
68 lines (55 loc) · 1.68 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
from __future__ import annotations
import logging
import os
import sys
from time import time
import examples
# Sets up the in-built logger to record key information and save it to a text file
logging.basicConfig(level=logging.INFO, filename='log.txt', filemode='w',
format="%(asctime)s - %(levelname)s - '%(message)s' - %(funcName)s")
logging.getLogger().addHandler(logging.StreamHandler(sys.stdout)) # Outputs the loggings into screen output
# Constants
ROOT_DIR = os.path.dirname(__file__)
START_TIME = time()
def quit_program() -> None:
"""
Closes python in a safe manner.
:return:
- None
"""
logging.info("Exiting program - %s seconds -" % round(time() - START_TIME, 2))
sys.exit(0)
def main() -> None:
"""
Gives the user a choice between tasks or datasets.
:return:
- None
"""
logging.info('Starting program')
while True:
print("""
0 - Quit
1 - Assignment 1 B
2 - Assignment 2 A
3 - Assignment 3 A
""")
choice = input("Which option number: ")
try:
choice = int(choice)
except ValueError:
print('\nPlease enter a valid response!')
choice = None
if choice is not None:
if choice == 0:
break
elif choice == 1:
examples.assignment_1_b.main(ROOT_DIR)
elif choice == 2:
examples.assignment_2_a.main(ROOT_DIR)
elif choice == 3:
examples.assignment_3_a.main(ROOT_DIR)
else:
print("\nPlease enter a valid choice!")
quit_program()
if __name__ == '__main__':
main()