-
Notifications
You must be signed in to change notification settings - Fork 64
/
parse_slave.py
46 lines (38 loc) · 1.3 KB
/
parse_slave.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
# -*- coding: utf-8 -*-
"""
parse_slave.py -- parses SSH cmd for invocation of smallfile_remote.py
Copyright 2012 -- Ben England
Licensed under the Apache License at http://www.apache.org/licenses/LICENSE-2.0
See Appendix on this page for instructions pertaining to license.
"""
import argparse
import os
import pickle
import time
import smallfile
def parse():
"""
parse command line and return unpickled test params
pass via --network-sync-dir option
optionally pass host identity of this remote invocation
"""
parser = argparse.ArgumentParser(description="parse remote smallfile parameters")
parser.add_argument(
"--network-sync-dir", help="directory used to synchronize with test driver"
)
parser.add_argument(
"--as-host",
default=smallfile.get_hostname(None),
help="directory used to synchronize with test driver",
)
args = parser.parse_args()
param_pickle_fname = os.path.join(args.network_sync_dir, "param.pickle")
if not os.path.exists(param_pickle_fname):
time.sleep(1.1)
params = None
with open(param_pickle_fname, "rb") as pickled_params:
params = pickle.load(pickled_params)
params.is_slave = True
params.as_host = args.as_host
params.master_invoke.onhost = args.as_host
return params