diff options
Diffstat (limited to 'tutorius')
-rw-r--r-- | tutorius/TProbe.py | 30 | ||||
-rw-r--r-- | tutorius/engine.py | 6 |
2 files changed, 18 insertions, 18 deletions
diff --git a/tutorius/TProbe.py b/tutorius/TProbe.py index dd27762..4e458a0 100644 --- a/tutorius/TProbe.py +++ b/tutorius/TProbe.py @@ -29,7 +29,7 @@ from . import addon from .services import ObjectStore from .properties import TPropContainer -from .dbustools import remote_call, save_args +from .dbustools import save_args, ignore, logError import copy """ @@ -289,7 +289,6 @@ class ProbeProxy: self._subscribedEvents = {} self._registeredCallbacks = {} - self._object.connect_to_signal("eventOccured", self._handle_signal, dbus_interface="org.tutorius.ProbeInterface") def _handle_signal(self, pickled_event): @@ -313,11 +312,11 @@ class ProbeProxy: def __update_action(self, action, callback, address): LOGGER.debug("ProbeProxy :: Updating action %s with address %s", str(action), str(address)) - self._actions[action] = str(address) + self._actions[address] = action callback(address) - def __clear_action(self, action): - self._actions.pop(action, None) + def __clear_action(self, address): + self._actions.pop(address, None) def install(self, action, action_installed_cb, error_cb): """ @@ -341,10 +340,12 @@ class ProbeProxy: @return None """ #TODO review how to make this work well - if not action_address in self._actions.values(): + if not action_address in self._actions.keys(): raise RuntimeWarning("Action not installed") #TODO Check error handling - return remote_call(self._probe.update, (action_address, pickle.dumps(newaction._props)), block=False) + return self._probe.update(action_address, pickle.dumps(newaction._props), + reply_handler=ignore, + error_handler=logError) def uninstall(self, action_address): """ @@ -353,11 +354,9 @@ class ProbeProxy: on action installation @param block Force a synchroneous dbus call if True """ - for (this_action, this_address) in self._actions.items(): - if this_address == action_address: - remote_call(self._probe.uninstall,(action_address,)) - del self._actions[this_action] - break + if action_address in self._actions: + self._actions.pop(action_address, None) + self._probe.uninstall(action_address, reply_handler=ignore, error_handler=logError) def __update_event(self, event, callback, event_subscribed_cb, address): LOGGER.debug("ProbeProxy :: Registered event %s with address %s", str(hash(event)), str(address)) @@ -437,9 +436,10 @@ class ProbeProxy: """ LOGGER.debug("ProbeProxy :: Unregister adress %s issued", str(address)) if address in self._subscribedEvents.keys(): - remote_call(self._probe.unsubscribe, (address,), - return_cb=save_args(self.__clear_event, address), - block=block) + self.__clear_event(address) + self._probe.unsubscribe(address, + reply_handler=save_args(self.__clear_event, address), + error_handler=logError) else: LOGGER.debug("ProbeProxy :: unsubscribe address %s failed : not registered", address) diff --git a/tutorius/engine.py b/tutorius/engine.py index c882d91..198fa11 100644 --- a/tutorius/engine.py +++ b/tutorius/engine.py @@ -141,7 +141,7 @@ class TutorialRunner(object): # Send all the event registration for (event_name, (event, next_state)) in transitions.items(): - self._pM.subscribe(event_name, event, + self._pM.subscribe(event, save_args(self._handleEvent, next_state), save_args(self.event_subscribed, event_name), save_args(self.subscribe_error, event_name)) @@ -190,8 +190,8 @@ class TutorialRunner(object): def _remove_subscribed_events(self): #Clear the EventFilters - for (event_name, event) in self._subscribed_events.items(): - self._pM.unsubscribe(event) + for (event_name, event_address) in self._subscribed_events.items(): + self._pM.unsubscribe(event_address) self._subscribed_events.clear() self._subscription_errors.clear() |