-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun.py
37 lines (26 loc) · 893 Bytes
/
run.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
import yaml
import json
import argparse
from munch import DefaultMunch
from genshop.application.app import App
from genshop.logger.logging import setup_logging
def get_config():
parser = argparse.ArgumentParser(description='General Shopper')
parser.add_argument('-config', help='a path to configuration file')
args = parser.parse_args()
filename = args.config
with open(filename, 'r') as file:
cfg_dict = yaml.load(file)
return DefaultMunch.fromDict(cfg_dict, None)
def system_start():
cfg = get_config()
if cfg is None:
raise Exception("Unable to extract the given config")
logger = setup_logging(cfg.application, 'genshop')
logger.info('Configurations: %s', json.dumps(cfg))
try:
App(cfg)
except Exception as err:
logger.info(f'App failed on {err}')
if __name__ == "__main__":
system_start()