Repository navigation
Expand file tree
/
Copy pathautorunx.py
More file actions
90 lines (81 loc) · 3.26 KB
/
Copy pathautorunx.py
File metadata and controls
90 lines (81 loc) · 3.26 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import sys
import os
import argparse
import globals
import json
parser = argparse.ArgumentParser()
parser.add_argument('-v', '--version',
action='version',
version='1.1.4',
help="checking version information"
)
parser.add_argument('-f', '--config-file',
required=True,
type=str,
help="specifies the configuration file to run")
parser.add_argument('-d', '--disable-config-file-system',
required=False,
action='store_true',
help="disables system setup from configuration file")
parser.add_argument('-l', '--system-node-lib-path',
required=False,
type=str,
help='set custom node library path')
parser.add_argument('-w', '--system-work-dir',
required=False,
type=str,
help='set working directory')
parser.add_argument('--system-aop-log-file',
required=False,
type=str,
help='set aop log file')
parser.add_argument('--system-aop-log-close',
required=False,
action='store_true',
help='set aop log close or not')
parser.add_argument('--system-log-common-log-file',
required=False,
type=str,
help='set common log file')
parser.add_argument('--system-log-function-log-file',
required=False,
type=str,
help='set function log file')
def main():
args = parser.parse_args()
if args.config_file is not None:
config_path = args.config_file
if not os.path.exists(config_path):
print("Invalid parameter: {}".format(config_path))
return
config = None
with open(config_path, "r", encoding="utf-8") as f:
config = json.load(f)
config['system'] = {'global':{}, 'node_center': {}, 'aop': {}, 'log': {}}
if args.disable_config_file_system:
config.pop('system', None)
if args.system_work_dir is not None:
config['system']['global']['ENV_WORK_DIR'] = args.system_work_dir
if args.system_node_lib_path is not None:
config['system']['node_center']['USER_LIB_PATH'] = args.system_node_lib_path
if args.system_aop_log_file is not None:
config['system']['aop']['AOP_LOG_FILE'] = args.system_aop_log_file
if args.system_aop_log_close:
config['system']['aop']['LOG_OPEN'] = False
else:
config['system']['aop']['LOG_OPEN'] = True
if args.system_log_common_log_file is not None:
config['system']['log']['COMMON_LOG_FILE'] = args.system_log_common_log_file
if args.system_log_function_log_file is not None:
config['system']['log']['LOG_FILE'] = args.system_log_function_log_file
globals.init(**config)
globals.start()
else:
parser.print_help()
def run(config):
with open(config, "r", encoding="utf-8") as f:
config = json.load(f)
globals.init(**config)
globals.start()
if __name__ == '__main__':
main()