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,7 +294,15 @@ 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)
""" """
try:
resp = self._ps.GetActivities() resp = self._ps.GetActivities()
except dbus.exceptions.DBusException, err:
logging.warn(
"""Unable to retrieve activity list from presence service: %s""",
err
)
return []
else:
acts = [] acts = []
for item in resp: for item in resp:
acts.append(self._new_object(item)) acts.append(self._new_object(item))
@ -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,7 +333,15 @@ 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)
""" """
try:
resp = self._ps.GetBuddies() resp = self._ps.GetBuddies()
except dbus.exceptions.DBusException, err:
logging.warn(
"""Unable to retrieve buddy-list from presence service: %s""",
err
)
return []
else:
buddies = [] buddies = []
for item in resp: for item in resp:
buddies.append(self._new_object(item)) buddies.append(self._new_object(item))
@ -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)