-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_client.py
41 lines (34 loc) · 1.27 KB
/
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
from dipla.client.client_factory import ClientFactory
from dipla.client.config_handler import ConfigHandler
import sys
import argparse
TK_AVAILABLE = True
try:
from dipla.client.ui import DiplaClientUI
except ImportError:
TK_AVAILABLE = False
def main(argv):
parser = argparse.ArgumentParser(description="Start a Dipla client.")
parser.add_argument('-c', default='', dest='config_path',
help="Optional path to a JSON config file")
parser.add_argument('--cores', default=1, dest='cores', type=int,
help="Number of concurrent clients to run")
parser.add_argument('--ui', action="store_true",
help="Use the Dipla Client UI")
args = parser.parse_args()
config = ConfigHandler()
if args.config_path:
config.parse_from_file(args.config_path)
if args.ui:
if not TK_AVAILABLE:
print("Please install tkinter to use UI")
sys.exit(1)
ui = DiplaClientUI(
config=config,
client_creator=ClientFactory.create_and_run_client,
stats_creator=ClientFactory.create_default_client_stats)
ui.run()
else:
ClientFactory.run_n_clients(args.cores, config)
if __name__ == '__main__':
main(sys.argv)