From 3227653cd311be9d4a09c5076fe3ec331d4d6a96 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 17 Oct 2007 12:53:24 +0100 Subject: [PATCH] Avoid misleading warning every time an activity starts (#4266) --- NEWS | 1 + lib/sugar/activity/activity.py | 8 +++++--- lib/sugar/presence/presenceservice.py | 19 +++++++++---------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/NEWS b/NEWS index 1e06b63f..8487dc83 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,4 @@ +* #4266 Avoid misleading warning every time an activity starts (smcv) * #4027 Try to make sugar.presence log messages less misleading (smcv) Snapshot 24fbd1ce1c diff --git a/lib/sugar/activity/activity.py b/lib/sugar/activity/activity.py index 2acb26b5..c0fcceec 100644 --- a/lib/sugar/activity/activity.py +++ b/lib/sugar/activity/activity.py @@ -318,9 +318,11 @@ class Activity(Window, gtk.Container): self._jobject = None # handle activity share/join - mesh_instance = self._pservice.get_activity(self._activity_id) - logging.debug("*** Act %s, mesh instance %r, scope %s" % (self._activity_id, mesh_instance, share_scope)) - if mesh_instance: + mesh_instance = self._pservice.get_activity(self._activity_id, + warn_if_none=False) + logging.debug("*** Act %s, mesh instance %r, scope %s", + self._activity_id, mesh_instance, share_scope) + if mesh_instance is not None: # There's already an instance on the mesh, join it logging.debug("*** Act %s joining existing mesh instance %r", self._activity_id, mesh_instance) self._shared_activity = mesh_instance diff --git a/lib/sugar/presence/presenceservice.py b/lib/sugar/presence/presenceservice.py index a9c834c9..dea0c7c8 100644 --- a/lib/sugar/presence/presenceservice.py +++ b/lib/sugar/presence/presenceservice.py @@ -302,21 +302,20 @@ class PresenceService(gobject.GObject): error_handler=lambda e:self._get_activities_error_cb(error_handler, e)) - def get_activity(self, activity_id): - """Retrieve single Activity object for the given unique id - - activity_id -- unique ID for the activity - - returns single Activity object or None if the activity + def get_activity(self, activity_id, warn_if_none=True): + """Retrieve single Activity object for the given unique id + + activity_id -- unique ID for the activity + + returns single Activity object or None if the activity is not found using GetActivityById on the service """ try: act_op = self._ps.GetActivityById(activity_id) except dbus.exceptions.DBusException, err: - _logger.warn( - """Unable to retrieve activity handle for %r from presence service: %s""" - % (activity_id, err) - ) + if warn_if_none: + _logger.warn("Unable to retrieve activity handle for %r from " + "presence service: %s", activity_id, err) return None return self._new_object(act_op)