forked from k9cdt/PKURunningHelper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runner.py
executable file
·50 lines (37 loc) · 1.27 KB
/
runner.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# filename: runner.py
from optparse import OptionParser
from util import (
Config, Logger,
json,
)
config = Config()
logger = Logger("runner")
parser = OptionParser(usage="PKU running helper ! Check your config first, then enjoy yourself !")
parser.add_option("-c", "--check", help="show 'config.ini' file", action="store_false")
parser.add_option("-s", "--start", help="run the runner's client", action="store_false")
options, args = parser.parse_args()
if options.check is not None:
for section in config.sections():
print("Section [%s]" % section)
print(json.dumps(dict(config[section]), indent=4))
print("\n")
elif options.start is not None:
app = config.get('Base', 'APP')
if app == 'PB':
from PB import PBClient as Client
elif app == "PKURunner":
from PKURunner import PKURunnerClient as Client
elif app == "Joyrun":
from Joyrun import JoyrunClient as Client
else:
raise ValueError("unsupported running APP -- %s !" % app)
try:
client = Client()
client.run()
except Exception as err:
logger.error("upload record failed !")
raise err
else:
logger.info("upload record success !")