diff options
| author | Nuno Santos <nsantos@apache.org> | 2011-09-08 20:27:49 +0000 |
|---|---|---|
| committer | Nuno Santos <nsantos@apache.org> | 2011-09-08 20:27:49 +0000 |
| commit | 7d5bce20c5ca6bc3869cbe2f6a73f1968c7a5abb (patch) | |
| tree | df38d7451902c9b1076d335ae9ea10cef92a9198 | |
| parent | 86b3e714b5f433d14d8909c927a8d7c97ed8b2cc (diff) | |
| download | qpid-python-7d5bce20c5ca6bc3869cbe2f6a73f1968c7a5abb.tar.gz | |
make 'qpid-config queues/exchanges <queue/exchange_name>' return proper error code, for scripting purposes
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1166888 13f79535-47bb-0310-9956-ffa450edef68
| -rwxr-xr-x | qpid/tools/src/py/qpid-config | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/qpid/tools/src/py/qpid-config b/qpid/tools/src/py/qpid-config index 3430eb6469..63fe66da67 100755 --- a/qpid/tools/src/py/qpid-config +++ b/qpid/tools/src/py/qpid-config @@ -102,6 +102,7 @@ class Config: self._flowStopSize = None self._flowResumeSize = None self._extra_arguments = [] + self._returnCode = 0 config = Config() @@ -359,9 +360,16 @@ class BrokerManager: caption1 = "Type " caption2 = "Exchange Name" maxNameLen = len(caption2) + found = False for ex in exchanges: if self.match(ex.name, filter): if len(ex.name) > maxNameLen: maxNameLen = len(ex.name) + found = True + if not found: + global config + config._returnCode = 1 + return + print "%s%-*s Attributes" % (caption1, maxNameLen, caption2) line = "" for i in range(((maxNameLen + len(caption1)) / 5) + 5): @@ -398,12 +406,18 @@ class BrokerManager: def QueueList(self, filter): queues = self.qmf.getObjects(_class="queue", _agent=self.brokerAgent) - caption = "Queue Name" maxNameLen = len(caption) + found = False for q in queues: if self.match(q.name, filter): if len(q.name) > maxNameLen: maxNameLen = len(q.name) + found = True + if not found: + global config + config._returnCode = 1 + return + print "%-*s Attributes" % (maxNameLen, caption) line = "" for i in range((maxNameLen / 5) + 5): @@ -675,7 +689,7 @@ def main(argv=None): print "Failed: %s: %s" % (e.__class__.__name__, e) return 1 - return 0 + return config._returnCode if __name__ == "__main__": sys.exit(main()) |
