summaryrefslogtreecommitdiff
path: root/python/commands
diff options
context:
space:
mode:
authorCarl C. Trieloff <cctrieloff@apache.org>2008-04-24 15:24:51 +0000
committerCarl C. Trieloff <cctrieloff@apache.org>2008-04-24 15:24:51 +0000
commit841ceb18e777e49ccddc189419265f5e0b20fedf (patch)
treecdd95ace16bdd35e40970ee6861f8b8e1c67c0ea /python/commands
parentd42b7bc8854f30c397c65641bc7adaeb21808e21 (diff)
downloadqpid-python-841ceb18e777e49ccddc189419265f5e0b20fedf.tar.gz
QPID-953 from tross
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@651290 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python/commands')
-rwxr-xr-xpython/commands/qpid-config10
-rwxr-xr-xpython/commands/qpid-queue-stats19
-rwxr-xr-xpython/commands/qpid-route10
-rwxr-xr-xpython/commands/qpid-tool8
4 files changed, 35 insertions, 12 deletions
diff --git a/python/commands/qpid-config b/python/commands/qpid-config
index 20b08933a4..03a0fd8538 100755
--- a/python/commands/qpid-config
+++ b/python/commands/qpid-config
@@ -19,7 +19,7 @@
# under the License.
#
-import os, uuid
+import os
import getopt
import sys
import socket
@@ -97,10 +97,11 @@ class BrokerManager:
def ConnectToBroker (self):
try:
self.spec = qpid.spec.load (_specpath)
+ self.sessionId = "%s.%d" % (os.uname()[1], os.getpid())
self.conn = Connection (connect (self.broker.host, self.broker.port), self.spec)
self.conn.start ()
self.mclient = managementClient (self.spec)
- self.mchannel = self.mclient.addChannel (self.conn.session(str(uuid.uuid4())))
+ self.mchannel = self.mclient.addChannel (self.conn.session(self.sessionId))
except socket.error, e:
print "Socket Error:", e
sys.exit (1)
@@ -108,6 +109,9 @@ class BrokerManager:
print "Connect Failed:", e
sys.exit (1)
+ def Disconnect (self):
+ self.mclient.removeChannel (self.mchannel)
+
def Overview (self):
self.ConnectToBroker ()
mc = self.mclient
@@ -374,4 +378,4 @@ else:
bm.Unbind (cargs[1:])
else:
Usage ()
-
+bm.Disconnect()
diff --git a/python/commands/qpid-queue-stats b/python/commands/qpid-queue-stats
index 6e3579edfd..ff28e5b50c 100755
--- a/python/commands/qpid-queue-stats
+++ b/python/commands/qpid-queue-stats
@@ -24,7 +24,6 @@ import getopt
import sys
import socket
import qpid
-import uuid
from threading import Condition
from qpid.management import managementClient
from qpid.peer import Closed
@@ -86,14 +85,18 @@ class BrokerManager:
def ConnectToBroker (self):
try:
self.spec = qpid.spec.load (specpath)
+ self.sessionId = "%s.%d" % (os.uname()[1], os.getpid())
self.conn = Connection (connect (self.broker.host, self.broker.port), self.spec)
self.conn.start ()
self.mclient = managementClient (self.spec, None, self.configCb, self.instCb)
- self.mchannel = self.mclient.addChannel (self.conn.session(str(uuid.uuid4())))
+ self.mchannel = self.mclient.addChannel (self.conn.session(self.sessionId))
except socket.error, e:
print "Connect Error:", e
exit (1)
+ def Disconnect (self):
+ self.mclient.removeChannel (self.mchannel)
+
def configCb (self, context, classKey, row, timestamps):
className = classKey[1]
if className != "queue":
@@ -131,12 +134,16 @@ class BrokerManager:
(name, deltaTime / 1000000000, obj.msgDepthLow, obj.msgDepthHigh, enqueueRate, dequeueRate)
- def Overview (self):
+ def Display (self):
self.ConnectToBroker ()
print "Queue Name Sec Depth Range Enq Rate Deq Rate"
print "==================================================================================================="
- while True:
- sleep (1)
+ try:
+ while True:
+ sleep (1)
+ except KeyboardInterrupt:
+ pass
+ self.Disconnect ()
##
## Main Program
@@ -156,4 +163,4 @@ for opt in optlist:
nargs = len (cargs)
bm = BrokerManager ()
bm.SetBroker (Broker (host))
-bm.Overview ()
+bm.Display ()
diff --git a/python/commands/qpid-route b/python/commands/qpid-route
index a0755641c9..a7fbb17777 100755
--- a/python/commands/qpid-route
+++ b/python/commands/qpid-route
@@ -23,7 +23,7 @@ import getopt
import sys
import socket
import qpid
-import uuid
+import os
from qpid.management import managementClient
from qpid.peer import Closed
from qpid.connection import Connection
@@ -80,15 +80,19 @@ class RouteManager:
print "Connecting to broker: %s:%d" % (broker.host, broker.port)
try:
self.spec = qpid.spec.load (_specpath)
+ self.sessionId = "%s.%d" % (os.uname()[1], os.getpid())
self.conn = Connection (connect (broker.host, broker.port), self.spec)
self.conn.start ()
self.mclient = managementClient (self.spec)
- self.mch = self.mclient.addChannel (self.conn.session(str(uuid.uuid4())))
+ self.mch = self.mclient.addChannel (self.conn.session(self.sessionId))
self.mclient.syncWaitForStable (self.mch)
except socket.error, e:
print "Connect Error:", e
sys.exit (1)
+ def Disconnect (self):
+ self.mclient.removeChannel (self.mch)
+
def getLink (self):
links = self.mclient.syncGetObjects (self.mch, "link")
for link in links:
@@ -268,4 +272,4 @@ else:
rm.ClearAllRoutes ()
else:
Usage ()
-
+rm.Disconnect ()
diff --git a/python/commands/qpid-tool b/python/commands/qpid-tool
index 02579b9d35..1aee3a1b7f 100755
--- a/python/commands/qpid-tool
+++ b/python/commands/qpid-tool
@@ -111,9 +111,17 @@ class Mcli (Cmd):
def do_EOF (self, data):
print "quit"
+ try:
+ self.dataObject.do_exit ()
+ except:
+ pass
return True
def do_quit (self, data):
+ try:
+ self.dataObject.do_exit ()
+ except:
+ pass
return True
def postcmd (self, stop, line):