Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tutorius/TProbe.py
diff options
context:
space:
mode:
Diffstat (limited to 'tutorius/TProbe.py')
-rw-r--r--tutorius/TProbe.py30
1 files changed, 17 insertions, 13 deletions
diff --git a/tutorius/TProbe.py b/tutorius/TProbe.py
index 37a5e0f..e58dd03 100644
--- a/tutorius/TProbe.py
+++ b/tutorius/TProbe.py
@@ -361,7 +361,7 @@ class ProbeProxy:
del self._actions[this_action]
break
- def __update_event(self, event, callback, address):
+ def __update_event(self, event, callback, event_subscribed_cb, address):
LOGGER.debug("ProbeProxy :: Registered event %s with address %s", str(hash(event)), str(address))
# Since multiple callbacks could be associated to the same
# event signature, we will store multiple callbacks
@@ -377,7 +377,7 @@ class ProbeProxy:
# TODO elavoie 2009-07-25 decide on a proper exception
# taxonomy
if self._registeredCallbacks[event].has_key(address):
- # Oups, how come we have two similar addresses?
+ # Oops, how come we have two similar addresses?
# send the bad news!
raise Exception("Probe subscribe exception, the following address already exists: " + str(address))
@@ -390,6 +390,7 @@ class ProbeProxy:
# our dictionary (python pass arguments by reference)
self._subscribedEvents[address] = copy.copy(event)
+ event_subscribed_cb(address)
return address
def __clear_event(self, address):
@@ -409,27 +410,25 @@ class ProbeProxy:
else:
LOGGER.debug("ProbeProxy :: unsubsribe address %s inconsistency : not registered", address)
- def subscribe(self, event, notification_cb, event_installed_cb=ignore, error_cb=logError, block=True):
+ def subscribe(self, event, notification_cb, event_subscribed_cb, error_cb):
"""
Register an event listener
@param event Event to listen for
@param notification_cb callable that will be called when the event occurs
@param event_installed_cb callable that will be called once the event is subscribed to
@param error_cb callable that will be called if the subscription fails
- @param block Force a synchroneous dbus call if True (Not allowed yet)
@return address identifier used for unsubscribing
"""
LOGGER.debug("ProbeProxy :: Registering event %s", str(hash(event)))
- if not block:
- raise RuntimeError("This function does not allow non-blocking mode yet")
+ #if not block:
+ # raise RuntimeError("This function does not allow non-blocking mode yet")
# TODO elavoie 2009-07-25 When we will allow for patterns both
# for event types and sources, we will need to revise the lookup
# mecanism for which callback function to call
- return remote_call(self._probe.subscribe, (pickle.dumps(event),),
- return_cb=save_args(self.__update_event, event, notification_cb),
- error_cb=save_args(error_cb, event),
- block=block)
+ self._probe.subscribe(pickle.dumps(event),
+ reply_handler=save_args(self.__update_event, event, notification_cb, event_subscribed_cb),
+ error_handler=save_args(error_cb, event))
def unsubscribe(self, address, block=True):
"""
@@ -529,15 +528,20 @@ class ProbeManager(object):
else:
raise RuntimeWarning("No activity attached")
- def subscribe(self, event, callback):
+ def subscribe(self, event, notification_cb, event_subscribed_cb, error_cb):
"""
Register an event listener
@param event Event to listen for
- @param callback callable that will be called when the event occurs
+ @param notification_cb callable that will be called when the event occurs
+ @param subscribe_cb callable that will be called once the action has been
+ installed
+ @param error_cb callable that will be called if an error happens during
+ installation
@return address identifier used for unsubscribing
"""
if self.currentActivity:
- return self._first_proxy(self.currentActivity).subscribe(event, callback)
+ return self._first_proxy(self.currentActivity).subscribe(event, notification_cb,\
+ event_subscribed_cb, error_cb)
else:
raise RuntimeWarning("No activity attached")