From b3039144e050555ad93c1ab18ae228b5b1970fb5 Mon Sep 17 00:00:00 2001 From: erick Date: Fri, 06 Nov 2009 15:50:06 +0000 Subject: Fixed probe tests --- (limited to 'tutorius/TProbe.py') diff --git a/tutorius/TProbe.py b/tutorius/TProbe.py index 1bd9935..08c9651 100644 --- a/tutorius/TProbe.py +++ b/tutorius/TProbe.py @@ -38,17 +38,23 @@ class TProbe(dbus.service.Object): a DBUS Interface. """ - def __init__(self, activity): + def __init__(self, activity, service_proxy=None): """ Create and register a TProbe for an activity. @param activity activity reference, must be a gtk container + @param service_proxy """ # Moving the ObjectStore assignment here, in the meantime # the reference to the activity shouldn't be share as a # global variable but passed by the Probe to the objects # that requires it self._activity = activity + + if service_proxy == None: + from .service import ServiceProxy + + self._service_proxy = service_proxy or ServiceProxy() ObjectStore().activity = activity @@ -70,8 +76,7 @@ class TProbe(dbus.service.Object): self._subscribedEvents = {} LOGGER.debug("TProbe :: registering '%s' with unique_id '%s'", self._activity_name, activity.get_id()) - from .service import ServiceProxy - ServiceProxy().register_probe(self._activity_name, self._unique_id) + self._service_proxy.register_probe(self._activity_name, self._unique_id) @@ -459,23 +464,6 @@ class ProbeManager(object): return self._current_activity currentActivity = property(fget=getCurrentActivity, fset=setCurrentActivity) - def attach(self, activity_id): - if activity_id in self._probes: - raise RuntimeWarning("Activity already attached") - - self._probes[activity_id] = [self._ProxyClass(activity_id)] - #TODO what do we do with this? Raise something? - if self._probes[activity_id].isAlive(): - print "Alive!" - else: - print "FAil!" - - def detach(self, activity_id): - if activity_id in self._probes: - probe = self._probes.pop(activity_id) - probe.detach() - if self._current_activity == activity_id: - self._current_activity = None def install(self, action, block=False): """ @@ -570,6 +558,20 @@ class ProbeManager(object): if len(proxies) == 0: self._probes.pop(process_name) + def get_registered_probes_list(self, process_name=None): + if process_name == None: + probe_list = [] + for probes in self._probes.itervalues(): + probe_list.extend(probes) + return probe_list + else: + if process_name in self._probes: + return self._probes[process_name] + else: + return [] + + + def _first_proxy(self, process_name): """ Returns the oldest probe connected under the process_name @@ -581,3 +583,4 @@ class ProbeManager(object): else: raise RuntimeWarning("No activity attached under '%s'", process_name) + -- cgit v0.9.1