diff options
| author | Siegfried-Angel Gevatter Pujals <siegfried@gevatter.com> | 2011-07-08 01:39:37 +0200 |
|---|---|---|
| committer | Siegfried-Angel Gevatter Pujals <siegfried@gevatter.com> | 2011-07-08 01:39:37 +0200 |
| commit | 73fdc3dd4ff4b3bd886f6bda53713417b14fcf02 (patch) | |
| tree | 2f3c3ca545399d2dcae9589d60e5377cbde6b341 | |
| parent | 01dea1d69048a0af519ab7987409e027ddfd4ede (diff) | |
| download | zeitgeist-73fdc3dd4ff4b3bd886f6bda53713417b14fcf02.tar.gz | |
Fix regression that broke properties (get_version and get_extensions).
| -rw-r--r-- | NEWS | 13 | ||||
| -rw-r--r-- | test/remote-test.py | 5 | ||||
| -rw-r--r-- | zeitgeist/client.py | 35 |
3 files changed, 33 insertions, 20 deletions
@@ -1,4 +1,15 @@ -2011-07-7: Zeitgeist 0.8.1 "The Snake and the Holy Grail" +2011-07-?: Zeitgeist 0.8.? "???" +-------------------------------- + +Engine: + + - ... + +Python API: + + - Fix regression that broke properties (get_version and get_extensions). + +2011-07-07: Zeitgeist 0.8.1 "The Snake and the Holy Grail" --------------------------------------------------------- Engine: diff --git a/test/remote-test.py b/test/remote-test.py index 3b7f71be..25a24e2d 100644 --- a/test/remote-test.py +++ b/test/remote-test.py @@ -562,7 +562,10 @@ class ZeitgeistRemotePropertiesTest(testutils.RemoteTestCase): def __init__(self, methodName): super(ZeitgeistRemotePropertiesTest, self).__init__(methodName) - + + def testVersion(self): + self.assertTrue(len(self.client.get_version()) >= 2) + def testExtensions(self): self.assertEquals( sorted(self.client.get_extensions()), diff --git a/zeitgeist/client.py b/zeitgeist/client.py index 44bf8101..fb81e5fe 100644 --- a/zeitgeist/client.py +++ b/zeitgeist/client.py @@ -67,15 +67,16 @@ class _DBusInterface(object): return methods, signals def reconnect(self): - self.__proxy = dbus.SessionBus().get_object(self.__iface.requested_bus_name, - self.__object_path) + self.__proxy = dbus.SessionBus().get_object( + self.__iface.requested_bus_name, self.__object_path) self.__iface = dbus.Interface(self.__proxy, self.__interface_name) self._load_introspection_data() - def _disconnection_safe(self, method_name, *args, **kwargs): + def _disconnection_safe(self, method_getter, *args, **kwargs): """ - Executes the given method. If it fails because the D-Bus connection - was lost, attempts to recover it and executes the method again. + Executes the method returned by method_getter. If it fails because + the D-Bus connection was lost, it attempts to recover it and executes + the method again. """ custom_error_handler = None @@ -87,8 +88,7 @@ class _DBusInterface(object): self.reconnect() # We don't use the reconnecting_error_handler here since that'd # get us into an endless loop if Zeitgeist really isn't there. - meth = getattr(self.__iface, method_name) - return meth(*args, **original_kwargs) + return method_getter()(*args, **original_kwargs) else: if custom_error_handler is not None: custom_error_handler(e) @@ -102,8 +102,7 @@ class _DBusInterface(object): kwargs['error_handler'] = reconnecting_error_handler try: - meth = getattr(self.__iface, method_name) - return meth(*args, **kwargs) + return method_getter()(*args, **kwargs) except dbus.exceptions.DBusException, e: return reconnecting_error_handler(e) @@ -115,9 +114,15 @@ class _DBusInterface(object): Method wrapping around a D-Bus call, which attempts to recover the connection to Zeitgeist if it got lost. """ - return self._disconnection_safe(name, *args, **kwargs) + return self._disconnection_safe( + lambda: getattr(self.__iface, name), *args, **kwargs) return _ProxyMethod + def get_property(self, property_name): + return self._disconnection_safe( + lambda: self.__proxy.get_dbus_method("Get", dbus.PROPERTIES_IFACE), + self.__interface_name, property_name) + def connect(self, signal, callback, **kwargs): """Connect a callback to a signal of the current proxy instance.""" if self.__signals is None: @@ -201,18 +206,12 @@ class ZeitgeistDBusInterface(object): def version(self): """Returns the API version""" dbus_interface = self.__shared_state["dbus_interface"] - return dbus_interface._disconnection_safe( - dbus_interface.proxy.get_dbus_method("Get", - dbus_interface=dbus.PROPERTIES_IFACE), - self.INTERFACE_NAME, "version") + return dbus_interface.get_property("version") def extensions(self): """Returns active extensions""" dbus_interface = self.__shared_state["dbus_interface"] - return dbus_interface._disconnection_safe( - dbus_interface.proxy.get_dbus_method("Get", - dbus_interface=dbus.PROPERTIES_IFACE), - self.INTERFACE_NAME, "extensions") + return dbus_interface.get_property("extensions") def get_extension(cls, name, path, busname=None): """ Returns an interface to the given extension. |
