master/client: remove function parameter

This commit is contained in:
Sebastien Bourdeauducq 2015-01-02 17:00:22 +08:00
parent 3befafc4e0
commit f352e7f752
3 changed files with 13 additions and 18 deletions

View File

@ -11,7 +11,7 @@ class _QueueStoreSyncer(ListSyncer):
def convert(self, x): def convert(self, x):
rid, run_params, timeout = x rid, run_params, timeout = x
row = [rid, run_params["file"]] 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)) row.append("-" if e is None else str(e))
return row return row
@ -29,7 +29,7 @@ class _PeriodicStoreSyncer:
next_run, run_params, timeout, period = x next_run, run_params, timeout, period = x
row = [time.strftime("%m/%d %H:%M:%S", time.localtime(next_run)), row = [time.strftime("%m/%d %H:%M:%S", time.localtime(next_run)),
prid, run_params["file"]] 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("-" if e is None else str(e))
row.append(str(period)) row.append(str(period))
return row return row
@ -81,10 +81,9 @@ class SchedulerWindow(Window):
notebook = Gtk.Notebook() notebook = Gtk.Notebook()
topvbox.pack_start(notebook, True, True, 0) 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) tree = Gtk.TreeView(self.queue_store)
for i, title in enumerate(["RID", "File", "Unit", for i, title in enumerate(["RID", "File", "Unit", "Timeout"]):
"Function", "Timeout"]):
renderer = Gtk.CellRendererText() renderer = Gtk.CellRendererText()
column = Gtk.TreeViewColumn(title, renderer, text=i) column = Gtk.TreeViewColumn(title, renderer, text=i)
tree.append_column(column) tree.append_column(column)
@ -105,10 +104,10 @@ class SchedulerWindow(Window):
vbox.set_border_width(6) vbox.set_border_width(6)
notebook.insert_page(vbox, Gtk.Label("Queue"), -1) 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) tree = Gtk.TreeView(self.periodic_store)
for i, title in enumerate(["Next run", "PRID", "File", "Unit", for i, title in enumerate(["Next run", "PRID", "File", "Unit",
"Function", "Timeout", "Period"]): "Timeout", "Period"]):
renderer = Gtk.CellRendererText() renderer = Gtk.CellRendererText()
column = Gtk.TreeViewColumn(title, renderer, text=i) column = Gtk.TreeViewColumn(title, renderer, text=i)
tree.append_column(column) tree.append_column(column)

View File

@ -8,7 +8,7 @@ from artiq.language.context import AutoContext
from artiq.management.dpdb import DeviceParamSupplier from artiq.management.dpdb import DeviceParamSupplier
def run(dps, file, unit, function): def run(dps, file, unit):
module = file_import(file) module = file_import(file)
if unit is None: if unit is None:
units = [v for k, v in module.__dict__.items() units = [v for k, v in module.__dict__.items()
@ -22,8 +22,7 @@ def run(dps, file, unit, function):
else: else:
unit = getattr(module, unit) unit = getattr(module, unit)
unit_inst = unit(dps) unit_inst = unit(dps)
f = getattr(unit_inst, function) unit_inst.run()
f()
def get_object(): def get_object():

View File

@ -33,8 +33,6 @@ def _get_args():
parser_add.add_argument( parser_add.add_argument(
"-t", "--timeout", default=None, type=float, "-t", "--timeout", default=None, type=float,
help="specify a timeout for the experiment to complete") 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, parser_add.add_argument("-u", "--unit", default=None,
help="unit to run") help="unit to run")
parser_add.add_argument("file", help="file containing the 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): def _action_submit(remote, args):
run_params = { run_params = {
"file": args.file, "file": args.file,
"unit": args.unit, "unit": args.unit
"function": args.function
} }
if args.periodic is None: if args.periodic is None:
rid = remote.run_once(run_params, args.timeout) rid = remote.run_once(run_params, args.timeout)
@ -117,10 +114,10 @@ def _action_del_parameter(remote, args):
def _show_queue(queue): def _show_queue(queue):
clear_screen() clear_screen()
if queue: if queue:
table = PrettyTable(["RID", "File", "Unit", "Function", "Timeout"]) table = PrettyTable(["RID", "File", "Unit", "Timeout"])
for rid, run_params, timeout in queue: for rid, run_params, timeout in queue:
row = [rid, run_params["file"]] 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) row.append("-" if x is None else x)
table.add_row(row) table.add_row(row)
print(table) print(table)
@ -131,13 +128,13 @@ def _show_queue(queue):
def _show_periodic(periodic): def _show_periodic(periodic):
clear_screen() clear_screen()
if periodic: if periodic:
table = PrettyTable(["Next run", "PRID", "File", "Unit", "Function", table = PrettyTable(["Next run", "PRID", "File", "Unit",
"Timeout", "Period"]) "Timeout", "Period"])
sp = sorted(periodic.items(), key=lambda x: (x[1][0], x[0])) sp = sorted(periodic.items(), key=lambda x: (x[1][0], x[0]))
for prid, (next_run, run_params, timeout, period) in sp: for prid, (next_run, run_params, timeout, period) in sp:
row = [time.strftime("%m/%d %H:%M:%S", time.localtime(next_run)), row = [time.strftime("%m/%d %H:%M:%S", time.localtime(next_run)),
prid, run_params["file"]] 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("-" if x is None else x)
row.append(period) row.append(period)
table.add_row(row) table.add_row(row)