-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__main__.py
40 lines (31 loc) · 922 Bytes
/
__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
import sys
import os
import yaml
def load_setting():
file_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "setting.yaml")
with open(file_path, 'r') as stream:
try:
file_str = stream.read()
if file_str:
_setting = yaml.load(file_str, Loader=yaml.FullLoader)
else:
exit(1)
except yaml.YAMLError as exc:
if hasattr(exc, 'problem_mark'):
mark = exc.problem_mark
exit(1)
return _setting["mode"].lower()
if __name__ == "__main__":
mode: str = ""
if len(sys.argv) == 2:
mode = sys.argv[1].lower()
else:
mode = load_setting()
if mode == "post":
from post import __main__
__main__.main()
elif mode == "tower":
from tower import __main__
__main__.main()
else:
print("Execution Failed")