summaryrefslogtreecommitdiff
path: root/qpid/python
diff options
context:
space:
mode:
authorAidan Skinner <aidan@apache.org>2009-09-17 16:21:13 +0000
committerAidan Skinner <aidan@apache.org>2009-09-17 16:21:13 +0000
commit7d6a028be9f6c47418e98a6fa74a359864428150 (patch)
tree78083427e88c48edb3b23605309e57f1301cba19 /qpid/python
parent31bbc100ac6b3a31eb25d29f407d60ff23334d1f (diff)
downloadqpid-python-7d6a028be9f6c47418e98a6fa74a359864428150.tar.gz
Merge from trunk
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/java-network-refactor@816261 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/python')
-rw-r--r--qpid/python/qpid/datatypes.py18
-rw-r--r--qpid/python/qpid/delegates.py8
-rw-r--r--qpid/python/qpid/ops.py5
-rw-r--r--qpid/python/tests/datatypes.py28
4 files changed, 54 insertions, 5 deletions
diff --git a/qpid/python/qpid/datatypes.py b/qpid/python/qpid/datatypes.py
index f832ddae34..61643715e4 100644
--- a/qpid/python/qpid/datatypes.py
+++ b/qpid/python/qpid/datatypes.py
@@ -234,6 +234,24 @@ class RangedSet:
def add(self, lower, upper = None):
self.add_range(Range(lower, upper))
+ def empty(self):
+ for r in self.ranges:
+ if r.lower <= r.upper:
+ return False
+ return True
+
+ def max(self):
+ if self.ranges:
+ return self.ranges[-1].upper
+ else:
+ return None
+
+ def min(self):
+ if self.ranges:
+ return self.ranges[0].lower
+ else:
+ return None
+
def __iter__(self):
return iter(self.ranges)
diff --git a/qpid/python/qpid/delegates.py b/qpid/python/qpid/delegates.py
index c74cc5a945..14111a88df 100644
--- a/qpid/python/qpid/delegates.py
+++ b/qpid/python/qpid/delegates.py
@@ -139,12 +139,18 @@ class Server(Delegate):
class Client(Delegate):
+ ppid = 0
+ try:
+ ppid = os.getppid()
+ except:
+ pass
+
PROPERTIES = {"product": "qpid python client",
"version": "development",
"platform": os.name,
"qpid.client_process": os.path.basename(sys.argv[0]),
"qpid.client_pid": os.getpid(),
- "qpid.client_ppid": os.getppid()}
+ "qpid.client_ppid": ppid}
def __init__(self, connection, username="guest", password="guest",
mechanism="PLAIN", heartbeat=None):
diff --git a/qpid/python/qpid/ops.py b/qpid/python/qpid/ops.py
index 447f9953df..11e7d11fe9 100644
--- a/qpid/python/qpid/ops.py
+++ b/qpid/python/qpid/ops.py
@@ -74,10 +74,7 @@ class Compound(object):
def dispatch(self, target, *args):
handler = "do_%s" % self.NAME
- if hasattr(target, handler):
- getattr(target, handler)(self, *args)
- else:
- print "UNHANDLED:", target, args
+ getattr(target, handler)(self, *args)
def __repr__(self, extras=()):
return "%s(%s)" % (self.__class__.__name__,
diff --git a/qpid/python/tests/datatypes.py b/qpid/python/tests/datatypes.py
index b00e5e78f8..00e649d6cf 100644
--- a/qpid/python/tests/datatypes.py
+++ b/qpid/python/tests/datatypes.py
@@ -148,6 +148,34 @@ class RangedSetTest(TestCase):
assert range.lower == 0
assert range.upper == 8
+ def testEmpty(self):
+ s = RangedSet()
+ assert s.empty()
+ s.add(0, -1)
+ assert s.empty()
+ s.add(0, 0)
+ assert not s.empty()
+
+ def testMinMax(self):
+ s = RangedSet()
+ assert s.max() is None
+ assert s.min() is None
+ s.add(0, 10)
+ assert s.max() == 10
+ assert s.min() == 0
+ s.add(0, 5)
+ assert s.max() == 10
+ assert s.min() == 0
+ s.add(0, 11)
+ assert s.max() == 11
+ assert s.min() == 0
+ s.add(15, 20)
+ assert s.max() == 20
+ assert s.min() == 0
+ s.add(-10, -5)
+ assert s.max() == 20
+ assert s.min() == -10
+
class RangeTest(TestCase):
def testIntersect1(self):