# HG changeset patch # User Dan Smith dsmith@danplanet.com # Date 1328673811 28800 # Node ID 4023f8be12127e2931858891f8f950e950554117 # Parent 5f81b0536807cb84da7685d1014dd7f44da9f3fb Allow setting a target for RadioJob other than the radio itself
This will facilitate synchronized jobs to the BankModel, Bank, etc objects
diff -r 5f81b0536807 -r 4023f8be1212 chirpui/common.py --- a/chirpui/common.py Tue Feb 07 20:03:31 2012 -0800 +++ b/chirpui/common.py Tue Feb 07 20:03:31 2012 -0800 @@ -53,6 +53,7 @@ self.args = args self.kwargs = kwargs self.desc = "Working" + self.target = None
def __str__(self): return "RadioJob(%s,%s,%s)" % (self.func, self.args, self.kwargs) @@ -63,13 +64,10 @@ def set_cb_args(self, *args): self.cb_args = args
- def execute(self, radio): - try: - func = getattr(radio, self.func) - except AttributeError, e: - print "No such radio function `%s'" % self.func - return + def set_target(self, target): + self.target = target
+ def _execute(self, target, func): try: DBG("Running %s (%s %s)" % (self.func, str(self.args), @@ -89,6 +87,18 @@ if self.cb: gobject.idle_add(self.cb, result, *self.cb_args)
+ def execute(self, radio): + if not self.target: + self.target = radio + + try: + func = getattr(self.target, self.func) + except AttributeError, e: + print "No such radio function `%s'" % self.func + return + + self._execute(self.target, func) + class RadioThread(threading.Thread, gobject.GObject): __gsignals__ = { "status" : (gobject.SIGNAL_RUN_LAST,