2014-10-05 16:25:31 +08:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import argparse
|
2014-10-23 18:48:03 +08:00
|
|
|
|
|
|
|
from artiq.management.pc_rpc import Client
|
2014-10-05 16:25:31 +08:00
|
|
|
|
|
|
|
|
|
|
|
def _get_args():
|
|
|
|
parser = argparse.ArgumentParser(description="ARTIQ client")
|
2014-10-23 19:07:36 +08:00
|
|
|
parser.add_argument(
|
|
|
|
"-s", "--server", default="::1",
|
|
|
|
help="hostname or IP of the master to connect to")
|
|
|
|
parser.add_argument(
|
|
|
|
"--port", default=8888, type=int,
|
|
|
|
help="TCP port to use to connect to the master")
|
2014-10-05 16:25:31 +08:00
|
|
|
parser.add_argument(
|
|
|
|
"-o", "--run-once", default=[], nargs=3,
|
|
|
|
action="append",
|
|
|
|
help="run experiment once. arguments: <path> <name> <timeout>")
|
|
|
|
parser.add_argument(
|
|
|
|
"-q", "--quit-master", default=False,
|
|
|
|
action="store_true",
|
|
|
|
help="causes the master to quit")
|
|
|
|
return parser.parse_args()
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
args = _get_args()
|
2014-10-23 19:07:36 +08:00
|
|
|
remote = Client(args.server, args.port)
|
2014-10-23 18:48:03 +08:00
|
|
|
try:
|
2014-10-05 16:25:31 +08:00
|
|
|
for path, name, timeout in args.run_once:
|
2014-10-23 18:48:03 +08:00
|
|
|
remote.run_once(
|
|
|
|
{
|
2014-10-05 16:25:31 +08:00
|
|
|
"path": path,
|
|
|
|
"name": name
|
2014-10-23 18:48:03 +08:00
|
|
|
}, int(timeout))
|
2014-10-05 16:25:31 +08:00
|
|
|
if args.quit_master:
|
2014-10-23 18:48:03 +08:00
|
|
|
remote.quit()
|
|
|
|
finally:
|
|
|
|
remote.close()
|
2014-10-05 16:25:31 +08:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|