-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_client.py
46 lines (36 loc) · 933 Bytes
/
run_client.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
# run_client
import argparse
import config
from typethief.client import Client
def parse_args():
parser = argparse.ArgumentParser(description='Run TypeThief client')
parser.add_argument(
'--config',
help='Configuration',
default='prod',
)
parser.add_argument(
'--host',
help='Server host',
default=None,
)
parser.add_argument(
'--port',
help='Server port',
default=None,
)
args = parser.parse_args()
if args.config not in config.CONFIGS:
parser.error('"{}" is not a valid configuration'.format(args.config))
conf = config.CONFIGS[args.config]
if not args.host:
args.host = conf.SERVER_HOST
if not args.port:
args.port = conf.SERVER_PORT
return args
def main():
args = parse_args()
cli = Client(args.host, args.port)
cli.run()
if __name__ == '__main__':
main()