From f352e7f7528de8173e08a3c96444713e927bff6a Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Fri, 2 Jan 2015 17:00:22 +0800 Subject: [PATCH] master/client: remove function parameter --- artiq/gui/scheduler.py | 13 ++++++------- artiq/management/worker_impl.py | 5 ++--- frontend/artiq_client.py | 13 +++++-------- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/artiq/gui/scheduler.py b/artiq/gui/scheduler.py index 559dcaaa2..16485b5f2 100644 --- a/artiq/gui/scheduler.py +++ b/artiq/gui/scheduler.py @@ -11,7 +11,7 @@ class _QueueStoreSyncer(ListSyncer): def convert(self, x): rid, run_params, timeout = x row = [rid, run_params["file"]] - for e in run_params["unit"], run_params["function"], timeout: + for e in run_params["unit"], timeout: row.append("-" if e is None else str(e)) return row @@ -29,7 +29,7 @@ class _PeriodicStoreSyncer: next_run, run_params, timeout, period = x row = [time.strftime("%m/%d %H:%M:%S", time.localtime(next_run)), prid, run_params["file"]] - for e in run_params["unit"], run_params["function"], timeout: + for e in run_params["unit"], timeout: row.append("-" if e is None else str(e)) row.append(str(period)) return row @@ -81,10 +81,9 @@ class SchedulerWindow(Window): notebook = Gtk.Notebook() topvbox.pack_start(notebook, True, True, 0) - self.queue_store = Gtk.ListStore(int, str, str, str, str) + self.queue_store = Gtk.ListStore(int, str, str, str) tree = Gtk.TreeView(self.queue_store) - for i, title in enumerate(["RID", "File", "Unit", - "Function", "Timeout"]): + for i, title in enumerate(["RID", "File", "Unit", "Timeout"]): renderer = Gtk.CellRendererText() column = Gtk.TreeViewColumn(title, renderer, text=i) tree.append_column(column) @@ -105,10 +104,10 @@ class SchedulerWindow(Window): vbox.set_border_width(6) notebook.insert_page(vbox, Gtk.Label("Queue"), -1) - self.periodic_store = Gtk.ListStore(str, int, str, str, str, str, str) + self.periodic_store = Gtk.ListStore(str, int, str, str, str, str) tree = Gtk.TreeView(self.periodic_store) for i, title in enumerate(["Next run", "PRID", "File", "Unit", - "Function", "Timeout", "Period"]): + "Timeout", "Period"]): renderer = Gtk.CellRendererText() column = Gtk.TreeViewColumn(title, renderer, text=i) tree.append_column(column) diff --git a/artiq/management/worker_impl.py b/artiq/management/worker_impl.py index 6026a2d2c..7e1b98e12 100644 --- a/artiq/management/worker_impl.py +++ b/artiq/management/worker_impl.py @@ -8,7 +8,7 @@ from artiq.language.context import AutoContext from artiq.management.dpdb import DeviceParamSupplier -def run(dps, file, unit, function): +def run(dps, file, unit): module = file_import(file) if unit is None: units = [v for k, v in module.__dict__.items() @@ -22,8 +22,7 @@ def run(dps, file, unit, function): else: unit = getattr(module, unit) unit_inst = unit(dps) - f = getattr(unit_inst, function) - f() + unit_inst.run() def get_object(): diff --git a/frontend/artiq_client.py b/frontend/artiq_client.py index f2f6b9dec..5269aae3b 100755 --- a/frontend/artiq_client.py +++ b/frontend/artiq_client.py @@ -33,8 +33,6 @@ def _get_args(): 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") @@ -79,8 +77,7 @@ def _get_args(): def _action_submit(remote, args): run_params = { "file": args.file, - "unit": args.unit, - "function": args.function + "unit": args.unit } if args.periodic is None: rid = remote.run_once(run_params, args.timeout) @@ -117,10 +114,10 @@ def _action_del_parameter(remote, args): def _show_queue(queue): clear_screen() if queue: - table = PrettyTable(["RID", "File", "Unit", "Function", "Timeout"]) + table = PrettyTable(["RID", "File", "Unit", "Timeout"]) for rid, run_params, timeout in queue: row = [rid, run_params["file"]] - for x in run_params["unit"], run_params["function"], timeout: + for x in run_params["unit"], timeout: row.append("-" if x is None else x) table.add_row(row) print(table) @@ -131,13 +128,13 @@ def _show_queue(queue): def _show_periodic(periodic): clear_screen() if periodic: - table = PrettyTable(["Next run", "PRID", "File", "Unit", "Function", + table = PrettyTable(["Next run", "PRID", "File", "Unit", "Timeout", "Period"]) sp = sorted(periodic.items(), key=lambda x: (x[1][0], x[0])) for prid, (next_run, run_params, timeout, period) in sp: row = [time.strftime("%m/%d %H:%M:%S", time.localtime(next_run)), prid, run_params["file"]] - for x in run_params["unit"], run_params["function"], timeout: + for x in run_params["unit"], timeout: row.append("-" if x is None else x) row.append(period) table.add_row(row)