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-12-08 19:22:02 +08:00
|
|
|
|
|
|
|
subparsers = parser.add_subparsers(dest="action")
|
|
|
|
|
|
|
|
parser_add = subparsers.add_parser("add", help="add an experiment")
|
|
|
|
parser_add.add_argument(
|
|
|
|
"-p", "--periodic", default=None, type=float,
|
|
|
|
help="run the experiment periodically every given number of seconds")
|
|
|
|
parser_add.add_argument(
|
|
|
|
"-t", "--timeout", default=None, type=float,
|
|
|
|
help="specify a timeout for the experiment to complete")
|
|
|
|
parser_add.add_argument("-f", "--function", default="run",
|
|
|
|
help="function to run")
|
|
|
|
parser_add.add_argument("-u", "--unit", default=None,
|
|
|
|
help="unit to run")
|
|
|
|
parser_add.add_argument("file", help="file containing the unit to run")
|
|
|
|
|
2014-10-05 16:25:31 +08:00
|
|
|
return parser.parse_args()
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
args = _get_args()
|
2014-10-28 15:45:56 +08:00
|
|
|
remote = Client(args.server, args.port, "master")
|
2014-10-23 18:48:03 +08:00
|
|
|
try:
|
2014-12-08 19:22:02 +08:00
|
|
|
if args.action == "add":
|
|
|
|
if args.periodic is None:
|
|
|
|
remote.run_once(
|
|
|
|
{
|
|
|
|
"file": args.file,
|
|
|
|
"unit": args.unit,
|
|
|
|
"function": args.function
|
|
|
|
}, args.timeout)
|
|
|
|
else:
|
|
|
|
raise NotImplementedError
|
2014-10-23 18:48:03 +08:00
|
|
|
finally:
|
2014-10-25 11:33:08 +08:00
|
|
|
remote.close_rpc()
|
2014-10-05 16:25:31 +08:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|