From 20d5eaf4bcae21985845cf132411a3f7dc66c0fb Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Thu, 26 Jul 2007 09:20:38 +0200 Subject: [PATCH 1/3] Add timeout arg to sugar.datastore.Datastore. --- NEWS | 1 + sugar/datastore/datastore.py | 5 +++-- sugar/datastore/dbus_helpers.py | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 72afe0ff..82b42983 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,4 @@ +* Add timeout arg to sugar.datastore.Datastore. (tomeu) * Turn off logging by default. Logs may be re-enabled on a per-module basis by adding environment variables like SHELL_DEBUG and RECORD_DEBUG to the sugar environment diff --git a/sugar/datastore/datastore.py b/sugar/datastore/datastore.py index ef1dd45a..256c12fa 100644 --- a/sugar/datastore/datastore.py +++ b/sugar/datastore/datastore.py @@ -172,7 +172,7 @@ def create(): metadata['mtime'] = metadata['ctime'] return DSObject(object_id=None, metadata=metadata, file_path=None) -def write(ds_object, update_mtime=True, reply_handler=None, error_handler=None): +def write(ds_object, update_mtime=True, reply_handler=None, error_handler=None, timeout=-1): logging.debug('datastore.write') properties = ds_object.metadata.get_dictionary().copy() @@ -185,7 +185,8 @@ def write(ds_object, update_mtime=True, reply_handler=None, error_handler=None): properties, ds_object.file_path, reply_handler=reply_handler, - error_handler=error_handler) + error_handler=error_handler, + timeout=timeout) else: ds_object.object_id = dbus_helpers.create(properties, ds_object.file_path) diff --git a/sugar/datastore/dbus_helpers.py b/sugar/datastore/dbus_helpers.py index 6680cc12..f0cfa3bf 100644 --- a/sugar/datastore/dbus_helpers.py +++ b/sugar/datastore/dbus_helpers.py @@ -37,12 +37,13 @@ def create(properties, filename): logging.debug('dbus_helpers.create: ' + object_id) return object_id -def update(uid, properties, filename, reply_handler=None, error_handler=None): +def update(uid, properties, filename, reply_handler=None, error_handler=None, timeout=-1): logging.debug('dbus_helpers.update: %s, %s, %s' % (uid, filename, properties)) if reply_handler and error_handler: _data_store.update(uid, dbus.Dictionary(properties), filename, reply_handler=reply_handler, - error_handler=error_handler) + error_handler=error_handler, + timeout=timeout) else: _data_store.update(uid, dbus.Dictionary(properties), filename) From 0a11ebafe87ac7a94c7e87b48c2e9dc035fb886e Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Thu, 26 Jul 2007 10:07:50 +0200 Subject: [PATCH 2/3] Increase activity launching timeout. --- NEWS | 2 ++ sugar/activity/activityfactory.py | 1 + 2 files changed, 3 insertions(+) diff --git a/NEWS b/NEWS index e256305c..7af32f56 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ +* Activity launching now timeout after 120 seconds. (marco) + Snapshot 088c7612e3 * Don't follow the cursor when expanding to secondary palette. (marco) diff --git a/sugar/activity/activityfactory.py b/sugar/activity/activityfactory.py index fe2a8bd7..404e5f4c 100644 --- a/sugar/activity/activityfactory.py +++ b/sugar/activity/activityfactory.py @@ -113,6 +113,7 @@ class ActivityCreationHandler(gobject.GObject): error_handler=self._notify_launch_error_handler) self._factory.create(self._activity_handle.get_dict(), + timeout=120 * 1000, reply_handler=self._no_reply_handler, error_handler=self._create_error_handler) From 0e45b8fcf1978f560713864e18a270719d7d4872 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Thu, 26 Jul 2007 11:08:31 +0200 Subject: [PATCH 3/3] Make sure the handle dict values are string. Looks like dbus-python get confused if they are dbus.String. --- sugar/activity/activityhandle.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sugar/activity/activityhandle.py b/sugar/activity/activityhandle.py index 8e90e705..0f2f2d9a 100644 --- a/sugar/activity/activityhandle.py +++ b/sugar/activity/activityhandle.py @@ -67,13 +67,15 @@ class ActivityHandle(object): def get_dict(self): """Retrieve our settings as a dictionary""" - result = { 'activity_id' : self.activity_id } + result = { } + if self.activity_id: + result['activity_id'] = str(self.activity_id) if self.pservice_id: - result['pservice_id'] = self.pservice_id + result['pservice_id'] = str(self.pservice_id) if self.object_id: - result['object_id'] = self.object_id + result['object_id'] = str(self.object_id) if self.uri: - result['uri'] = self.uri + result['uri'] = str(self.uri) return result