qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonat...@apache.org
Subject svn commit: r1062221 - in /qpid/trunk/qpid/tools/src/py: qpid-config qpid-route
Date Sat, 22 Jan 2011 18:13:35 GMT
Author: jonathan
Date: Sat Jan 22 18:13:34 2011
New Revision: 1062221

URL: http://svn.apache.org/viewvc?rev=1062221&view=rev
Log:
qpid-route now correctly shows usage for invalid command lines.

Fixes an error introduced by an earlier commit. Also modified
qpid-config for consistency.

Modified:
    qpid/trunk/qpid/tools/src/py/qpid-config
    qpid/trunk/qpid/tools/src/py/qpid-route

Modified: qpid/trunk/qpid/tools/src/py/qpid-config
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/tools/src/py/qpid-config?rev=1062221&r1=1062220&r2=1062221&view=diff
==============================================================================
--- qpid/trunk/qpid/tools/src/py/qpid-config (original)
+++ qpid/trunk/qpid/tools/src/py/qpid-config Sat Jan 22 18:13:34 2011
@@ -25,6 +25,56 @@ import sys
 import locale
 from qmf.console import Session
 
+usage = """
+Usage:  qpid-config [OPTIONS]
+        qpid-config [OPTIONS] exchanges [filter-string]
+        qpid-config [OPTIONS] queues    [filter-string]
+        qpid-config [OPTIONS] add exchange <type> <name> [AddExchangeOptions]
+        qpid-config [OPTIONS] del exchange <name>
+        qpid-config [OPTIONS] add queue <name> [AddQueueOptions]
+        qpid-config [OPTIONS] del queue <name> [DelQueueOptions]
+        qpid-config [OPTIONS] bind   <exchange-name> <queue-name> [binding-key]
+                  <for type xml>     [-f -|filename]
+                  <for type header>  [all|any] k1=v1 [, k2=v2...]
+        qpid-config [OPTIONS] unbind <exchange-name> <queue-name> [binding-key]"""
+
+description = """
+ADDRESS syntax:
+
+      [username/password@] hostname
+      ip-address [:<port>]
+
+Examples:
+
+$ qpid-config add queue q
+$ qpid-config add exchange direct d localhost:5672
+$ qpid-config exchanges 10.1.1.7:10000
+$ qpid-config queues guest/guest@broker-host:10000
+
+Add Exchange <type> values:
+
+    direct     Direct exchange for point-to-point communication
+    fanout     Fanout exchange for broadcast communication
+    topic      Topic exchange that routes messages using binding keys with wildcards
+    headers    Headers exchange that matches header fields against the binding keys
+    xml        XML Exchange - allows content filtering using an XQuery
+
+
+Queue Limit Actions
+
+    none (default) - Use broker's default policy
+    reject         - Reject enqueued messages
+    flow-to-disk   - Page messages to disk
+    ring           - Replace oldest unacquired message with new
+    ring-strict    - Replace oldest message, reject if oldest is acquired
+
+Queue Ordering Policies
+
+    fifo (default) - First in, first out
+    lvq            - Last Value Queue ordering, allows queue browsing
+    lvq-no-browse  - Last Value Queue ordering, browsing clients may lose data"""
+
+
 class Config:
     def __init__(self):
         self._recursive         = False
@@ -77,7 +127,7 @@ class JHelpFormatter(IndentedHelpFormatt
             return ""
 
 def Usage():
-    print "qpid-config: invalid arguments. Try $ qpid-config --help"
+    print usage
     exit(-1)
 
 def OptionsAndArguments(argv):
@@ -85,54 +135,6 @@ def OptionsAndArguments(argv):
 
     global config
 
-    usage = """
-    Usage:  qpid-config [OPTIONS]
-            qpid-config [OPTIONS] exchanges [filter-string]
-            qpid-config [OPTIONS] queues    [filter-string]
-            qpid-config [OPTIONS] add exchange <type> <name> [AddExchangeOptions]
-            qpid-config [OPTIONS] del exchange <name>
-            qpid-config [OPTIONS] add queue <name> [AddQueueOptions]
-            qpid-config [OPTIONS] del queue <name> [DelQueueOptions]
-            qpid-config [OPTIONS] bind   <exchange-name> <queue-name> [binding-key]
-                      <for type xml>     [-f -|filename]
-                      <for type header>  [all|any] k1=v1 [, k2=v2...]
-            qpid-config [OPTIONS] unbind <exchange-name> <queue-name> [binding-key]"""
-
-    description = """
-    ADDRESS syntax:   
-
-          [username/password@] hostname
-          ip-address [:<port>]
-
-    Examples:
-
-    $ qpid-config add queue q
-    $ qpid-config add exchange direct d localhost:5672
-    $ qpid-config exchanges 10.1.1.7:10000
-    $ qpid-config queues guest/guest@broker-host:10000
-
-    Add Exchange <type> values:
-
-        direct     Direct exchange for point-to-point communication
-        fanout     Fanout exchange for broadcast communication
-        topic      Topic exchange that routes messages using binding keys with wildcards
-        headers    Headers exchange that matches header fields against the binding keys
-        xml        XML Exchange - allows content filtering using an XQuery
-
-
-    Queue Limit Actions
-
-        none (default) - Use broker's default policy
-        reject         - Reject enqueued messages
-        flow-to-disk   - Page messages to disk
-        ring           - Replace oldest unacquired message with new
-        ring-strict    - Replace oldest message, reject if oldest is acquired
-
-    Queue Ordering Policies
-
-        fifo (default) - First in, first out
-        lvq            - Last Value Queue ordering, allows queue browsing
-        lvq-no-browse  - Last Value Queue ordering, browsing clients may lose data"""
 
     parser = OptionParser(usage=usage,
                           description=description,
@@ -240,7 +242,7 @@ def OptionsAndArguments(argv):
 
 #
 # accept -f followed by either
-# a filename or "-", for stdin.  pull the bits into a string, to be 
+# a filename or "-", for stdin.  pull the bits into a string, to be
 # passed to the xml binding.
 #
 def snarf_xquery_args():
@@ -254,7 +256,7 @@ def snarf_xquery_args():
         res = f.read()
         f.close()
     return [True, res]
-    
+
 #
 # look for "any"/"all" and grok the rest of argv into a map
 #
@@ -279,7 +281,7 @@ class BrokerManager:
         self.brokerName = None
         self.qmf        = None
         self.broker     = None
-        self.mechanism  = None 
+        self.mechanism  = None
 
     def SetBroker(self, brokerUrl, mechanism):
         self.url = brokerUrl
@@ -355,7 +357,7 @@ class BrokerManager:
                         if queue != None:
                             qname = queue.name
                         print "    bind [%s] => %s" % (bind.bindingKey, qname)
-            
+
 
     def QueueList(self, filter):
         queues = self.qmf.getObjects(_class="queue", _agent=self.brokerAgent)
@@ -502,7 +504,7 @@ class BrokerManager:
             # this checks/imports the -f arg
             [ok, xquery] = snarf_xquery_args()
             _args = { "xquery" : xquery }
-        else:            
+        else:
             if res.type == "headers":
                 [ok, op, kv] = snarf_header_args(args[3:])
                 _args = kv
@@ -619,4 +621,4 @@ def main(argv=None):
 
 if __name__ == "__main__":
         sys.exit(main())
-        
+

Modified: qpid/trunk/qpid/tools/src/py/qpid-route
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/tools/src/py/qpid-route?rev=1062221&r1=1062220&r2=1062221&view=diff
==============================================================================
--- qpid/trunk/qpid/tools/src/py/qpid-route (original)
+++ qpid/trunk/qpid/tools/src/py/qpid-route Sat Jan 22 18:13:34 2011
@@ -26,6 +26,31 @@ import os
 import locale
 from qmf.console import Session, BrokerURL
 
+usage = """
+Usage:  qpid-route [OPTIONS] dynamic add <dest-broker> <src-broker> <exchange>
[tag] [exclude-list]
+        qpid-route [OPTIONS] dynamic del <dest-broker> <src-broker> <exchange>
+
+        qpid-route [OPTIONS] route add   <dest-broker> <src-broker> <exchange>
<routing-key> [tag] [exclude-list] [mechanism]
+        qpid-route [OPTIONS] route del   <dest-broker> <src-broker> <exchange>
<routing-key>
+        qpid-route [OPTIONS] queue add   <dest-broker> <src-broker> <exchange>
<queue>
+        qpid-route [OPTIONS] queue del   <dest-broker> <src-broker> <exchange>
<queue>
+        qpid-route [OPTIONS] route list  [<dest-broker>]
+        qpid-route [OPTIONS] route flush [<dest-broker>]
+        qpid-route [OPTIONS] route map   [<broker>]
+
+        qpid-route [OPTIONS] link add  <dest-broker> <src-broker>
+        qpid-route [OPTIONS] link del  <dest-broker> <src-broker>
+        qpid-route [OPTIONS] link list [<dest-broker>]"""
+
+description = """
+ADDRESS syntax:
+
+      [username/password@] hostname
+      ip-address [:<port>]"""
+
+def Usage():
+    print usage
+
 class Config:
     def __init__(self):
         self._verbose   = False
@@ -54,35 +79,7 @@ class JHelpFormatter(IndentedHelpFormatt
         else:
             return ""
 
-def usage(parser):
-    parser.print_help()
-    exit(-1)
-
-usage = """
-Usage:  qpid-route [OPTIONS] dynamic add <dest-broker> <src-broker> <exchange>
[tag] [exclude-list]
-        qpid-route [OPTIONS] dynamic del <dest-broker> <src-broker> <exchange>
-
-        qpid-route [OPTIONS] route add   <dest-broker> <src-broker> <exchange>
<routing-key> [tag] [exclude-list] [mechanism]
-        qpid-route [OPTIONS] route del   <dest-broker> <src-broker> <exchange>
<routing-key>
-        qpid-route [OPTIONS] queue add   <dest-broker> <src-broker> <exchange>
<queue>
-        qpid-route [OPTIONS] queue del   <dest-broker> <src-broker> <exchange>
<queue>
-        qpid-route [OPTIONS] route list  [<dest-broker>]
-        qpid-route [OPTIONS] route flush [<dest-broker>]
-        qpid-route [OPTIONS] route map   [<broker>]
-
-        qpid-route [OPTIONS] link add  <dest-broker> <src-broker>
-        qpid-route [OPTIONS] link del  <dest-broker> <src-broker>
-        qpid-route [OPTIONS] link list [<dest-broker>]"""
-
-description = """
-ADDRESS syntax:   
-
-      [username/password@] hostname
-      ip-address [:<port>]"""
-
-
 def OptionsAndArguments(argv):
-         
     parser = OptionParser(usage=usage,
                           description=description,
                           formatter=JHelpFormatter())
@@ -472,7 +469,7 @@ class RoutePair:
             self.bidir = True
             return True
         return False
-        
+
 
 def YN(val):
     if val == 1:
@@ -485,7 +482,8 @@ def main(argv=None):
     args = OptionsAndArguments(argv)
     nargs = len(args)
     if nargs < 2:
-        usage(parser)
+        Usage()
+        return(-1)
 
     if nargs == 2:
         localBroker = socket.gethostname()
@@ -507,11 +505,13 @@ def main(argv=None):
         if group == "link":
             if cmd == "add":
                 if nargs != 4:
-                    usage(parser)
+                    Usage()
+                    return(-1)
                 rm.addLink(remoteBroker)
             elif cmd == "del":
                 if nargs != 4:
-                    usage(parser)
+                    Usage()
+                    return(-1)
                 rm.delLink(remoteBroker)
             elif cmd == "list":
                 rm.listLinks()
@@ -519,35 +519,39 @@ def main(argv=None):
         elif group == "dynamic":
             if cmd == "add":
                 if nargs < 5 or nargs > 7:
-                    usage(parser)
+                    Usage()
+                    return(-1)
 
                 tag = ""
                 excludes = ""
                 mech = "PLAIN"
-                if nargs > 5: tag = args[5]     
-                if nargs > 6: excludes = args[6]     
+                if nargs > 5: tag = args[5]
+                if nargs > 6: excludes = args[6]
                 rm.addRoute(remoteBroker, args[4], "", tag, excludes, mech, dynamic=True)
             elif cmd == "del":
                 if nargs != 5:
-                    usage(parser)
+                    Usage()
+                    return(-1)
                 else:
                     rm.delRoute(remoteBroker, args[4], "", dynamic=True)
 
         elif group == "route":
             if cmd == "add":
                 if nargs < 6 or nargs > 9:
-                    usage(parser)
+                    Usage()
+                    return(-1)
 
                 tag = ""
                 excludes = ""
                 mech = "PLAIN"
-                if nargs > 6: tag = args[6]     
+                if nargs > 6: tag = args[6]
                 if nargs > 7: excludes = args[7]
                 if nargs > 8: mech = args[8]
                 rm.addRoute(remoteBroker, args[4], args[5], tag, excludes, mech, dynamic=False)
             elif cmd == "del":
                 if nargs != 6:
-                    usage(parser)
+                    Usage()
+                    return(-1)
                 rm.delRoute(remoteBroker, args[4], args[5], dynamic=False)
             elif cmd == "map":
                 rm.mapRoutes()
@@ -557,17 +561,20 @@ def main(argv=None):
                 elif cmd == "flush":
                     rm.clearAllRoutes()
                 else:
-                    usage(parser)
+                    Usage()
+                    return(-1)
 
         elif group == "queue":
             if nargs != 6:
-                usage(parser)
+                Usage()
+                return(-1)
             if cmd == "add":
                 rm.addQueueRoute(remoteBroker, exchange=args[4], queue=args[5])
             elif cmd == "del":
                 rm.delQueueRoute(remoteBroker, exchange=args[4], queue=args[5])
             else:
-                usage(parser)
+                Usage()
+                return(-1)
 
     except Exception,e:
         if rm:



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message