diff options
author | Carl C. Trieloff <cctrieloff@apache.org> | 2008-02-28 18:55:21 +0000 |
---|---|---|
committer | Carl C. Trieloff <cctrieloff@apache.org> | 2008-02-28 18:55:21 +0000 |
commit | 89bf8bee0cb748de137f1826a3d96a78414dd1f0 (patch) | |
tree | 254aa94fff96467908f655328a0c1c305fd6f2b0 /qpid/python/mgmt-cli/main.py | |
parent | 68ac10aa1fbe38a326d828ddbf9dd2bfeba28426 (diff) | |
download | qpid-python-89bf8bee0cb748de137f1826a3d96a78414dd1f0.tar.gz |
QPID-820 from tross
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@632087 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/python/mgmt-cli/main.py')
-rwxr-xr-x | qpid/python/mgmt-cli/main.py | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/qpid/python/mgmt-cli/main.py b/qpid/python/mgmt-cli/main.py index 76e1f25c14..f4c22012eb 100755 --- a/qpid/python/mgmt-cli/main.py +++ b/qpid/python/mgmt-cli/main.py @@ -104,7 +104,10 @@ class Mcli (Cmd): self.dataObject.do_list (data) def do_call (self, data): - self.dataObject.do_call (data) + try: + self.dataObject.do_call (data) + except ValueError, e: + print "ValueError:", e def do_EOF (self, data): print "quit" @@ -121,7 +124,10 @@ class Mcli (Cmd): self.dataObject.close () def Usage (): - print sys.argv[0], "[<target-host> [<tcp-port>]]" + print "Usage:", sys.argv[0], "[OPTIONS] [<target-host> [<tcp-port>]]" + print + print "Options:" + print " -s <amqp-spec-file> default: /usr/share/amqp/amqp.0-10-preview.xml" print sys.exit (1) @@ -134,13 +140,15 @@ try: (optlist, cargs) = getopt.getopt (sys.argv[1:], 's:') except: Usage () + exit (1) specpath = "/usr/share/amqp/amqp.0-10-preview.xml" host = "localhost" port = 5672 -if "s" in optlist: - specpath = optlist["s"] +for opt in optlist: + if opt[0] == "-s": + specpath = opt[1] if len (cargs) > 0: host = cargs[0] @@ -148,19 +156,27 @@ if len (cargs) > 0: if len (cargs) > 1: port = int (cargs[1]) -print ("Management Tool for QPID") disp = Display () # Attempt to make a connection to the target broker try: - data = ManagementData (disp, host, port, spec=specpath) + data = ManagementData (disp, host, port, specfile=specpath) except socket.error, e: - sys.exit (0) + print "Socket Error:", e[1] + sys.exit (1) except Closed, e: if str(e).find ("Exchange not found") != -1: print "Management not enabled on broker: Use '-m yes' option on broker startup." - sys.exit (0) + sys.exit (1) +except IOError, e: + print "IOError: %d - %s: %s" % (e.errno, e.strerror, e.filename) + sys.exit (1) # Instantiate the CLI interpreter and launch it. cli = Mcli (data, disp) -cli.cmdloop () +print ("Management Tool for QPID") +try: + cli.cmdloop () +except Closed, e: + print "Connection to Broker Lost:", e + exit (1) |