You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by mc...@apache.org on 2013/09/18 23:15:16 UTC
svn commit: r1524572 - in /qpid/trunk/qpid:
cpp/bindings/qpid/python/ChangeLog python/examples/api/drain
python/examples/api/hello python/examples/api/hello_xml
python/examples/api/server python/examples/api/spout
python/examples/api/statistics.py
Author: mcpierce
Date: Wed Sep 18 21:15:16 2013
New Revision: 1524572
URL: http://svn.apache.org/r1524572
Log:
QPID-4924: Fixed the Python examples to use the new Python module
Now the imports will first attempt to bring in qpid_messaging, the Swig
generated Python. If that fails it will then fall back to trying to
import qpid.messaging, the pure Python binding.
Modified:
qpid/trunk/qpid/cpp/bindings/qpid/python/ChangeLog
qpid/trunk/qpid/python/examples/api/drain
qpid/trunk/qpid/python/examples/api/hello
qpid/trunk/qpid/python/examples/api/hello_xml
qpid/trunk/qpid/python/examples/api/server
qpid/trunk/qpid/python/examples/api/spout
qpid/trunk/qpid/python/examples/api/statistics.py
Modified: qpid/trunk/qpid/cpp/bindings/qpid/python/ChangeLog
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/bindings/qpid/python/ChangeLog?rev=1524572&r1=1524571&r2=1524572&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/bindings/qpid/python/ChangeLog (original)
+++ qpid/trunk/qpid/cpp/bindings/qpid/python/ChangeLog Wed Sep 18 21:15:16 2013
@@ -1,4 +1,5 @@
Version 0.26:
* QPID-4952: Changed the module name to qpid_messaging.
* QPID-5140: Added get/set method to MessageProperties.
-
+ * QPID-4924: Added examples from pure Python libraries.
+ * Added the console example to interact with server.
Modified: qpid/trunk/qpid/python/examples/api/drain
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/python/examples/api/drain?rev=1524572&r1=1524571&r2=1524572&view=diff
==============================================================================
--- qpid/trunk/qpid/python/examples/api/drain (original)
+++ qpid/trunk/qpid/python/examples/api/drain Wed Sep 18 21:15:16 2013
@@ -7,9 +7,9 @@
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -19,7 +19,12 @@
#
import optparse
-from qpid.messaging import *
+
+try:
+ from qpid_messaging import *
+except:
+ from qpid.messaging import *
+
from qpid.util import URL
from qpid.log import enable, DEBUG, WARN
Modified: qpid/trunk/qpid/python/examples/api/hello
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/python/examples/api/hello?rev=1524572&r1=1524571&r2=1524572&view=diff
==============================================================================
--- qpid/trunk/qpid/python/examples/api/hello (original)
+++ qpid/trunk/qpid/python/examples/api/hello Wed Sep 18 21:15:16 2013
@@ -7,9 +7,9 @@
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -19,15 +19,19 @@
#
import sys
-from qpid.messaging import *
+
+try:
+ from qpid_messaging import *
+except:
+ from qpid.messaging import *
if len(sys.argv)<2:
- broker = "localhost:5672"
+ broker = "localhost:5672"
else:
broker = sys.argv[1]
-if len(sys.argv)<3:
- address = "amq.topic"
+if len(sys.argv)<3:
+ address = "amq.topic"
else:
address = sys.argv[2]
Modified: qpid/trunk/qpid/python/examples/api/hello_xml
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/python/examples/api/hello_xml?rev=1524572&r1=1524571&r2=1524572&view=diff
==============================================================================
--- qpid/trunk/qpid/python/examples/api/hello_xml (original)
+++ qpid/trunk/qpid/python/examples/api/hello_xml Wed Sep 18 21:15:16 2013
@@ -7,9 +7,9 @@
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -19,7 +19,11 @@
#
import sys
-from qpid.messaging import *
+
+try:
+ from qpid_messaging import *
+except:
+ from qpid.messaging import *
broker = "localhost:5672"
connection = Connection(broker)
@@ -41,11 +45,11 @@ try:
address = """
xml; {
- create: always,
- node:{ type: queue },
- link: {
+ create: always,
+ node:{ type: queue },
+ link: {
x-bindings: [{ exchange: xml, key: weather, arguments: { xquery: %r} }]
- }
+ }
}
""" % query
Modified: qpid/trunk/qpid/python/examples/api/server
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/python/examples/api/server?rev=1524572&r1=1524571&r2=1524572&view=diff
==============================================================================
--- qpid/trunk/qpid/python/examples/api/server (original)
+++ qpid/trunk/qpid/python/examples/api/server Wed Sep 18 21:15:16 2013
@@ -7,9 +7,9 @@
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -19,7 +19,12 @@
#
import optparse, sys, traceback
-from qpid.messaging import *
+
+try:
+ from qpid_messaging import *
+except:
+ from qpid.messaging import *
+
from qpid.util import URL
from subprocess import Popen, STDOUT, PIPE
from qpid.log import enable, DEBUG, WARN
@@ -62,10 +67,10 @@ def dispatch(msg):
result.properties["exit"] = proc.returncode
elif msg_type == "eval":
try:
- content = eval(msg.content)
+ content = str(eval(msg.content))
except:
content = traceback.format_exc()
- result = Message(content)
+ result = Message(content = content)
else:
result = Message("unrecognized message type: %s" % msg_type)
return result
Modified: qpid/trunk/qpid/python/examples/api/spout
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/python/examples/api/spout?rev=1524572&r1=1524571&r2=1524572&view=diff
==============================================================================
--- qpid/trunk/qpid/python/examples/api/spout (original)
+++ qpid/trunk/qpid/python/examples/api/spout Wed Sep 18 21:15:16 2013
@@ -7,9 +7,9 @@
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -19,7 +19,13 @@
#
import optparse, time
-from qpid.messaging import *
+
+try:
+ from qpid_messaging import *
+ from uuid import uuid4
+except:
+ from qpid.messaging import *
+
from qpid.util import URL
from qpid.log import enable, DEBUG, WARN
Modified: qpid/trunk/qpid/python/examples/api/statistics.py
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/python/examples/api/statistics.py?rev=1524572&r1=1524571&r2=1524572&view=diff
==============================================================================
--- qpid/trunk/qpid/python/examples/api/statistics.py (original)
+++ qpid/trunk/qpid/python/examples/api/statistics.py Wed Sep 18 21:15:16 2013
@@ -48,16 +48,16 @@ class Throughput(Statistic):
return "tp(m/s)"
def report(self):
- if self.started:
+ if self.started:
elapsed = time.time() - self.start
return str(int(self.messages/elapsed))
- else:
- return "0"
+ else:
+ return "0"
class ThroughputAndLatency(Throughput):
def __init__(self):
- Throughput.__init__(self)
+ Throughput.__init__(self)
self.total = 0.0
self.min = float('inf')
self.max = -float('inf')
@@ -82,8 +82,8 @@ class ThroughputAndLatency(Throughput):
def report(self):
output = Throughput.report(self)
if (self.samples > 0):
- output += "\t%.2f\t%.2f\t%.2f" %(self.min, self.max, self.total/self.samples)
- return output
+ output += "\t%.2f\t%.2f\t%.2f" %(self.min, self.max, self.total/self.samples)
+ return output
# Report batch and overall statistics
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org