More code to handle service-offline cases and log messages to tell the

user/admin what's going on.
This commit is contained in:
Mike C. Fletcher 2007-04-22 00:31:32 -04:00
parent a7af5b06cd
commit 96ab3a10fe

View File

@ -294,11 +294,19 @@ class PresenceService(gobject.GObject):
returns list of Activity objects for all object paths returns list of Activity objects for all object paths
the service reports exist (using GetActivities) the service reports exist (using GetActivities)
""" """
resp = self._ps.GetActivities() try:
acts = [] resp = self._ps.GetActivities()
for item in resp: except dbus.exceptions.DBusException, err:
acts.append(self._new_object(item)) logging.warn(
return acts """Unable to retrieve activity list from presence service: %s""",
err
)
return []
else:
acts = []
for item in resp:
acts.append(self._new_object(item))
return acts
def get_activity(self, activity_id): def get_activity(self, activity_id):
"""Retrieve single Activity object for the given unique id """Retrieve single Activity object for the given unique id
@ -310,7 +318,12 @@ class PresenceService(gobject.GObject):
""" """
try: try:
act_op = self._ps.GetActivityById(activity_id) act_op = self._ps.GetActivityById(activity_id)
except dbus.exceptions.DBusException: except dbus.exceptions.DBusException, err:
logging.warn(
"""Unable to retrieve activity handle for %r from presence service: %s""",
activity_id,
err
)
return None return None
return self._new_object(act_op) return self._new_object(act_op)
@ -320,11 +333,19 @@ class PresenceService(gobject.GObject):
returns list of Buddy objects for all object paths returns list of Buddy objects for all object paths
the service reports exist (using GetBuddies) the service reports exist (using GetBuddies)
""" """
resp = self._ps.GetBuddies() try:
buddies = [] resp = self._ps.GetBuddies()
for item in resp: except dbus.exceptions.DBusException, err:
buddies.append(self._new_object(item)) logging.warn(
return buddies """Unable to retrieve buddy-list from presence service: %s""",
err
)
return []
else:
buddies = []
for item in resp:
buddies.append(self._new_object(item))
return buddies
def get_buddy(self, key): def get_buddy(self, key):
"""Retrieve single Buddy object for the given public key """Retrieve single Buddy object for the given public key
@ -337,7 +358,12 @@ class PresenceService(gobject.GObject):
""" """
try: try:
buddy_op = self._ps.GetBuddyByPublicKey(dbus.ByteArray(key)) buddy_op = self._ps.GetBuddyByPublicKey(dbus.ByteArray(key))
except dbus.exceptions.DBusException: except dbus.exceptions.DBusException, err:
logging.warn(
"""Unable to retrieve buddy handle for %r from presence service: %s""",
key,
err
)
return None return None
return self._new_object(buddy_op) return self._new_object(buddy_op)
@ -350,7 +376,11 @@ class PresenceService(gobject.GObject):
""" """
try: try:
owner_op = self._ps.GetOwner() owner_op = self._ps.GetOwner()
except dbus.exceptions.DBusException: except dbus.exceptions.DBusException, err:
logging.warn(
"""Unable to retrieve local user/owner from presence service: %s""",
err
)
return None return None
return self._new_object(owner_op) return self._new_object(owner_op)