pidgin: ecca5667: Handle D-Bus errors more helpfully in pu...

resiak at pidgin.im resiak at pidgin.im
Thu Jul 3 13:42:10 EDT 2008


-----------------------------------------------------------------
Revision: ecca56677b874f6fc528aa97dc3bb49118c6483e
Ancestor: 372a5b358b4d8f8552f5696bf1260c9191734c8b
Author: resiak at pidgin.im
Date: 2008-07-03T15:38:49
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/ecca56677b874f6fc528aa97dc3bb49118c6483e

Modified files:
        libpurple/purple-url-handler

ChangeLog: 

Handle D-Bus errors more helpfully in purple-url-handler.
If there's no libpurple object on the bus, then we'll never get to the uber
exception handler that previously swallowed all exceptions and suggested that
maybe no client is running.

-------------- next part --------------
============================================================
--- libpurple/purple-url-handler	b12c31e71e8e57952f79ed972a986d21399c631c
+++ libpurple/purple-url-handler	6f3d8d3629829318c883f9e1168c1554d8a7eade
@@ -6,7 +6,15 @@ import urllib
 import time
 import urllib
 
-obj = dbus.SessionBus().get_object("im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject")
+bus = dbus.SessionBus()
+obj = None
+try:
+    obj = bus.get_object("im.pidgin.purple.PurpleService",
+                         "/im/pidgin/purple/PurpleObject")
+except dbus.DBusException, e:
+    if e._dbus_error_name == "org.freedesktop.DBus.Error.ServiceUnknown":
+        print "Error: no libpurple-powered client is running. Try starting Pidgin or Finch."
+        sys.exit(1)
 purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface")
 
 class CheckedObject:
@@ -328,9 +336,9 @@ def main(argv=sys.argv):
             ymsgr(uri)
         else:
             print "Unknown protocol: %s" % type
-    except dbus.dbus_bindings.DBusException:
-        print "ERROR: Is there a libpurple-powered client (e.g. Pidgin or Finch) running?"
+    except dbus.DBusException, e:
+        print "Error: %s" % (e.message)
+        sys.exit(1)
 
-
 if __name__ == "__main__":
     main()


More information about the Commits mailing list