From 7c81300e2e183c8f4bffe06a7541b46fb2635cae Mon Sep 17 00:00:00 2001 From: erick Date: Sun, 01 Nov 2009 01:05:47 +0000 Subject: Added a ProbeManager to the service and added a minimal but working automatic registering for Probes on activity startup --- (limited to 'tutorius/service.py') diff --git a/tutorius/service.py b/tutorius/service.py index eb246a1..70efc80 100644 --- a/tutorius/service.py +++ b/tutorius/service.py @@ -2,6 +2,9 @@ import dbus from .engine import Engine from .dbustools import remote_call +from .TProbe import ProbeManager +import logging +LOGGER = logging.getLogger("sugar.tutorius.service") _DBUS_SERVICE = "org.tutorius.Service" _DBUS_PATH = "/org/tutorius/Service" @@ -19,11 +22,13 @@ class Service(dbus.service.Object): self._engine = None + self._probeMgr = ProbeManager() + def start(self): """ Start the service itself """ # For the moment there is nothing to do - pass + LOGGER.debug("Service.start()") @dbus.service.method(_DBUS_SERVICE_IFACE, @@ -50,6 +55,35 @@ class Service(dbus.service.Object): """ self._engine.pause() + @dbus.service.method(_DBUS_SERVICE_IFACE, + in_signature="ss", out_signature="") + def register_probe(self, process_name, unique_id): + """ Adds a probe to the known probes, to be used by a tutorial. + + A generic name for a process (like an Activity) is passed + so that the execution of a tutorial will use that generic + name. However, a unique id is also passed to differentiate + between many instances of the same process. + + @param process_name The generic name of a process + @param unique_id The unique identification associated to this + process + """ + LOGGER.debug("Service.register_probe(%s,%s)", process_name, unique_id) + self._probeMgr.register_probe(process_name, unique_id) + + @dbus.service.method(_DBUS_SERVICE_IFACE, + in_signature="s", out_signature="") + def unregister_probe(self, unique_id): + """ Remove a probe from the known probes. + + @param process_name The generic name of a process + @param unique_id The unique identification associated to this + process + """ + LOGGER.debug("Service.unregister_probe(%s)", unique_id) + self._probeMgr.unregister_probe(unique_id) + class ServiceProxy: """ Proxy to connect to the Service object, abstracting the DBus interface""" @@ -74,6 +108,29 @@ class ServiceProxy: """ remote_call(self._service.pause, (), block=False) + def register_probe(self, process_name, unique_id): + """ Adds a probe to the known probes, to be used by a tutorial. + + A generic name for a process (like an Activity) is passed + so that the execution of a tutorial will use that generic + name. However, a unique id is also passed to differentiate + between many instances of the same process. + + @param process_name The generic name of a process + @param unique_id The unique identification associated to this + process + """ + self._service.register_probe(process_name,unique_id) + + def unregister_probe(self, unique_id): + """ Remove a probe from the known probes. + + @param process_name The generic name of a process + @param unique_id The unique identification associated to this + process + """ + self._service.unregister_probe(unique_id) + if __name__ == "__main__": import dbus.mainloop.glib import gobject -- cgit v0.9.1