forked from nrasadi/global-state-snapshot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
41 lines (33 loc) · 1.25 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
import argparse
import shutil
from bank import Bank
from inspector import Inspector
from commons import Constants
if __name__ == '__main__':
# create and parse arguments
ap = argparse.ArgumentParser()
ap.add_argument("-b", "--bank", required=False, action='store_true',
help="Use this option to run an instance of Bank (a branch).")
ap.add_argument("-i", "--inspector", required=False, action='store_true',
help="Use this option to run the inspector")
ap.add_argument("-c", "--clear", required=False, action='store_true',
help="Clear the branches information file.")
args = ap.parse_args()
if args.clear:
try:
shutil.rmtree(Constants.dir_logs)
shutil.rmtree(Constants.dir_bank)
print("bank/ and logs/ directories were removed.")
except FileNotFoundError:
print("directories do not exist. They were already removed.")
exit(0)
if args.bank and args.inspector:
raise "You must only use one option."
elif args.bank:
branch = Bank()
branch.run()
elif args.inspector:
inspector = Inspector()
inspector.run()
else:
raise "Use one of the options (-b or -i)"