changeset 23072:4b4be7609072

Import a patch (with changes) from Debian: * 20_purple-remote_friendly.patch: - Make error messages friendlier when python-dbus is not installed or if someone calls purple-remote/purple-url-handler with --help or -h (Closes: #413204) committer: Richard Laager <rlaager@wiktel.com>
author Ari Pollak <ari@debian.org>
date Wed, 21 May 2008 21:05:09 +0000
parents 67148f43fd2f
children be8c6b5cc726
files libpurple/purple-remote libpurple/purple-url-handler
diffstat 2 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/purple-remote	Mon May 12 02:03:13 2008 +0000
+++ b/libpurple/purple-remote	Wed May 21 21:05:09 2008 +0000
@@ -35,7 +35,7 @@
             raise "Error: " + self.attr + " " + str(args) + " returned " + str(result)
         return result
             
-def show_help():
+def show_help(requested=False):
     print """This program uses D-Bus to communicate with purple.
 
 Usage:
@@ -66,6 +66,10 @@
     PurpleAccountsFindConnected?name=&protocol=prpl-jabber
     PurpleAccountsFindConnected(,prpl-jabber)
 """ % sys.argv[0]
+    if (requested):
+        sys.exit(0)
+    else:
+        sys.exit(1)
 
 cpurple = CheckedObject(purple)
 
@@ -213,10 +217,11 @@
                                 raise "Don't know how to handle type \"%s\"" % type
                     return purple.__getattr__(command)(*methodparams)
             show_help()
-            raise "Unknown command: %s" % command
 
 if len(sys.argv) == 1:
     show_help()
+elif (sys.argv[1] == "--help" or sys.argv[1] == "-h"):
+    show_help(True)
 elif (obj == None):
     print "No existing libpurple instance detected."
     sys.exit(1);
--- a/libpurple/purple-url-handler	Mon May 12 02:03:13 2008 +0000
+++ b/libpurple/purple-url-handler	Wed May 21 21:05:09 2008 +0000
@@ -295,10 +295,14 @@
 
 
 def main(argv=sys.argv):
-    if len(argv) != 2:
+    if len(argv) != 2 or argv[1] == "--help" or argv[1] == "-h":
         print "Usage: %s URI" % argv[0]
         print "Example: %s \"xmpp:romeo@montague.net?message\"" % argv[0]
-        return
+
+        if len(argv) != 2:
+            sys.exit(1)
+        else:
+            return 0
 
     uri = argv[1]
     type = uri.split(":")[0]