From af4be9a2e2e1d43aa2d03690e6d931c1bae584f0 Mon Sep 17 00:00:00 2001 From: Yann Sionneau Date: Wed, 11 Feb 2015 18:13:16 +0100 Subject: [PATCH] rpctool: change call syntax --- artiq/frontend/artiq_rpctool.py | 13 +------------ doc/manual/utilities.rst | 15 +++++---------- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/artiq/frontend/artiq_rpctool.py b/artiq/frontend/artiq_rpctool.py index 2ade18b08..876abb978 100755 --- a/artiq/frontend/artiq_rpctool.py +++ b/artiq/frontend/artiq_rpctool.py @@ -71,18 +71,7 @@ def list_methods(remote): def call_method(remote, method_name, args): method = getattr(remote, method_name) - if args != []: - args = eval(" ".join(args)) - try: - iter(args) - except TypeError: - # not iterable - ret = method(args) - else: - # iterable - ret = method(*args) - else: - ret = method() + ret = method(*[eval(arg) for arg in args]) if ret is not None: print("{}".format(ret)) diff --git a/doc/manual/utilities.rst b/doc/manual/utilities.rst index c6f4d0dc7..6c135c3d8 100644 --- a/doc/manual/utilities.rst +++ b/doc/manual/utilities.rst @@ -56,20 +56,15 @@ in order to call remote functions of an ARTIQ controller. $ artiq_rpctool.py ::1 3253 call -t lda set_attenuation 5 In general, to call a function named ``f`` with N arguments named - respectively ``x1, x2, ..., xN``. + respectively ``x1, x2, ..., xN`` you can do:: - You must pass them as a Python iterable object:: - - $ artiq_rpctool.py hostname port call -t target f '(x1, x2, ..., xN)' + $ artiq_rpctool.py hostname port call -t target f x1 x2 ... xN You can use Python syntax to compute arguments as they will be passed - to the ``eval()`` primitive:: + to the ``eval()`` primitive. But beware to use quotes to separate + arguments which use spaces:: - $ artiq_rpctool.py hostname port call -t target f '(x*3+5 for x in range(8))' - $ artiq_rpctool.py hostname port call -t target f 'range(5)' - - If you only need one argument, you don't need to pass an iterable, a - single value is accepted. + $ artiq_rpctool.py hostname port call -t target f '3 * 4 + 2' True '[1, 2]' If the called function has a return value, it will get printed to the standard output if the value is not None like in the standard