From d60cc6ae3995063480ce412b307f578a3d1e72cc Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 27 Sep 2007 18:49:54 +0000 Subject: activityfactory: Cope with dbus-python 0.82.2's fix to non-default timeouts. In 0.82.1 async call timeouts were wrongly in milliseconds, in >= 0.82.2 they are correctly in seconds. Synchronous timeouts have always been in seconds. This patch can be simplified once dbus-python gets into builds (#3903). --- diff --git a/sugar/activity/activityfactory.py b/sugar/activity/activityfactory.py index 1041747..4143978 100644 --- a/sugar/activity/activityfactory.py +++ b/sugar/activity/activityfactory.py @@ -29,6 +29,13 @@ from sugar import util import os +# #3903 - this constant can be removed and assumed to be 1 when dbus-python +# 0.82.3 is the only version used +if dbus.version >= (0, 82, 3): + DBUS_PYTHON_TIMEOUT_UNITS_PER_SECOND = 1 +else: + DBUS_PYTHON_TIMEOUT_UNITS_PER_SECOND = 1000 + _SHELL_SERVICE = "org.laptop.Shell" _SHELL_PATH = "/org/laptop/Shell" _SHELL_IFACE = "org.laptop.Shell" @@ -143,7 +150,7 @@ class ActivityCreationHandler(gobject.GObject): if not os.path.exists('/etc/olpc-security'): handle = self._handle.get_dict() self._factory.create(dbus.Dictionary(handle, signature='ss'), - timeout=120 * 1000, + timeout=120 * DBUS_PYTHON_TIMEOUT_UNITS_PER_SECOND, reply_handler=self._no_reply_handler, error_handler=self._create_error_handler) else: @@ -153,7 +160,7 @@ class ActivityCreationHandler(gobject.GObject): factory.CreateActivity( self._service_name, self._handle.get_dict(), - timeout=120 * 1000, + timeout=120 * DBUS_PYTHON_TIMEOUT_UNITS_PER_SECOND, reply_handler=self._create_reply_handler, error_handler=self._create_error_handler, dbus_interface=_RAINBOW_ACTIVITY_FACTORY_INTERFACE) -- cgit v0.9.1