You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kg...@apache.org on 2015/04/22 17:00:31 UTC
[1/5] qpid-proton git commit: PROTON-490: futurize proton-c
Repository: qpid-proton
Updated Branches:
refs/heads/kgiusti-python3 903c72469 -> e87a6d313
PROTON-490: futurize proton-c
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/677729af
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/677729af
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/677729af
Branch: refs/heads/kgiusti-python3
Commit: 677729af4f4eea3076bfe493ad217b65aa125178
Parents: 81085e3
Author: Ken Giusti <kg...@apache.org>
Authored: Thu Apr 16 14:13:54 2015 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Mon Apr 20 12:45:16 2015 -0400
----------------------------------------------------------------------
proton-c/mllib/__init__.py | 10 +++-
proton-c/mllib/dom.py | 5 +-
proton-c/mllib/parsers.py | 3 +-
proton-c/mllib/transforms.py | 3 +-
proton-c/src/codec/encodings.h.py | 17 ++++---
proton-c/src/protocol.h.py | 91 +++++++++++++++++-----------------
6 files changed, 70 insertions(+), 59 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/677729af/proton-c/mllib/__init__.py
----------------------------------------------------------------------
diff --git a/proton-c/mllib/__init__.py b/proton-c/mllib/__init__.py
index 9aa1e56..c6fccf1 100644
--- a/proton-c/mllib/__init__.py
+++ b/proton-c/mllib/__init__.py
@@ -22,16 +22,22 @@ This module provides document parsing and transformation utilities for
both SGML and XML.
"""
-import os, dom, transforms, parsers, sys
+from __future__ import absolute_import
+
+import os, sys
import xml.sax, types
from xml.sax.handler import ErrorHandler
from xml.sax.xmlreader import InputSource
from cStringIO import StringIO
+from . import dom
+from . import transforms
+from . import parsers
+
def transform(node, *args):
result = node
for t in args:
- if isinstance(t, types.ClassType):
+ if isinstance(t, type):
t = t()
result = result.dispatch(t)
return result
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/677729af/proton-c/mllib/dom.py
----------------------------------------------------------------------
diff --git a/proton-c/mllib/dom.py b/proton-c/mllib/dom.py
index 486f708..4cbac26 100644
--- a/proton-c/mllib/dom.py
+++ b/proton-c/mllib/dom.py
@@ -24,8 +24,8 @@ Simple DOM for both SGML and XML documents.
from __future__ import division
from __future__ import generators
from __future__ import nested_scopes
+from __future__ import absolute_import
-import transforms
class Container:
@@ -109,6 +109,7 @@ class Node(Container, Component, Dispatcher):
return nd
def text(self):
+ from . import transforms
return self.dispatch(transforms.Text())
def tag(self, name, *attrs, **kwargs):
@@ -238,7 +239,7 @@ class Flatten(View):
sources = [iter(self.source)]
while sources:
try:
- nd = sources[-1].next()
+ nd = next(sources[-1])
if isinstance(nd, Tree):
sources.append(iter(nd.children))
else:
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/677729af/proton-c/mllib/parsers.py
----------------------------------------------------------------------
diff --git a/proton-c/mllib/parsers.py b/proton-c/mllib/parsers.py
index 3e7cc10..e71018d 100644
--- a/proton-c/mllib/parsers.py
+++ b/proton-c/mllib/parsers.py
@@ -20,9 +20,10 @@
"""
Parsers for SGML and XML to dom.
"""
+from __future__ import absolute_import
import sgmllib, xml.sax.handler
-from dom import *
+from .dom import *
class Parser:
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/677729af/proton-c/mllib/transforms.py
----------------------------------------------------------------------
diff --git a/proton-c/mllib/transforms.py b/proton-c/mllib/transforms.py
index 69d9912..383add3 100644
--- a/proton-c/mllib/transforms.py
+++ b/proton-c/mllib/transforms.py
@@ -20,8 +20,9 @@
"""
Useful transforms for dom objects.
"""
+from __future__ import absolute_import
-import dom
+from . import dom
from cStringIO import StringIO
class Visitor:
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/677729af/proton-c/src/codec/encodings.h.py
----------------------------------------------------------------------
diff --git a/proton-c/src/codec/encodings.h.py b/proton-c/src/codec/encodings.h.py
index 71fb9ea..9f08c6c 100755
--- a/proton-c/src/codec/encodings.h.py
+++ b/proton-c/src/codec/encodings.h.py
@@ -18,16 +18,17 @@
# under the License.
#
+from __future__ import print_function
import mllib, optparse, os, sys
xml = os.path.join(os.path.dirname(__file__), "types.xml")
doc = mllib.xml_parse(xml)
-print "/* generated from %s */" % xml
-print "#ifndef _PROTON_ENCODINGS_H"
-print "#define _PROTON_ENCODINGS_H 1"
-print
-print "#define PNE_DESCRIPTOR (0x00)"
+print("/* generated from %s */" % xml)
+print("#ifndef _PROTON_ENCODINGS_H")
+print("#define _PROTON_ENCODINGS_H 1")
+print()
+print("#define PNE_DESCRIPTOR (0x00)")
for enc in doc.query["amqp/section/type/encoding"]:
name = enc["@name"] or enc.parent["@name"]
@@ -35,7 +36,7 @@ for enc in doc.query["amqp/section/type/encoding"]:
if name == "ieee-754":
name = enc.parent["@name"]
cname = "PNE_" + name.replace("-", "_").upper()
- print "#define %s%s(%s)" % (cname, " "*(20-len(cname)), enc["@code"])
+ print("#define %s%s(%s)" % (cname, " "*(20-len(cname)), enc["@code"]))
-print
-print "#endif /* encodings.h */"
+print()
+print("#endif /* encodings.h */")
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/677729af/proton-c/src/protocol.h.py
----------------------------------------------------------------------
diff --git a/proton-c/src/protocol.h.py b/proton-c/src/protocol.h.py
index 76a2391..bbc0dfe 100644
--- a/proton-c/src/protocol.h.py
+++ b/proton-c/src/protocol.h.py
@@ -18,20 +18,21 @@
# under the License.
#
+from __future__ import print_function
from protocol import *
-print "/* generated */"
-print "#ifndef _PROTON_PROTOCOL_H"
-print "#define _PROTON_PROTOCOL_H 1"
-print
-print "#include \"proton/type_compat.h\""
+print("/* generated */")
+print("#ifndef _PROTON_PROTOCOL_H")
+print("#define _PROTON_PROTOCOL_H 1")
+print()
+print("#include \"proton/type_compat.h\"")
fields = {}
for type in TYPES:
fidx = 0
for f in type.query["field"]:
- print "#define %s_%s (%s)" % (field_kw(type), field_kw(f), fidx)
+ print("#define %s_%s (%s)" % (field_kw(type), field_kw(f), fidx))
fidx += 1
idx = 0
@@ -39,14 +40,14 @@ idx = 0
for type in TYPES:
desc = type["descriptor"]
name = type["@name"].upper().replace("-", "_")
- print "#define %s_SYM (\"%s\")" % (name, desc["@name"])
+ print("#define %s_SYM (\"%s\")" % (name, desc["@name"]))
hi, lo = [int(x, 0) for x in desc["@code"].split(":")]
code = (hi << 32) + lo
- print "#define %s ((uint64_t) %s)" % (name, code)
+ print("#define %s ((uint64_t) %s)" % (name, code))
fields[code] = (type["@name"], [f["@name"] for f in type.query["field"]])
idx += 1
-print """
+print("""
#include <stddef.h>
typedef struct {
@@ -61,43 +62,43 @@ extern const uint16_t FIELD_NAME[];
extern const uint16_t FIELD_FIELDS[];
extern const unsigned char FIELD_MIN;
extern const unsigned char FIELD_MAX;
-"""
+""")
-print "#ifdef DEFINE_FIELDS"
+print("#ifdef DEFINE_FIELDS")
-print 'struct FIELD_STRINGS {'
-print ' const char FIELD_STRINGS_NULL[sizeof("")];'
+print('struct FIELD_STRINGS {')
+print(' const char FIELD_STRINGS_NULL[sizeof("")];')
strings = set()
for name, fnames in fields.values():
strings.add(name)
strings.update(fnames)
for str in strings:
istr = str.replace("-", "_");
- print ' const char FIELD_STRINGS_%s[sizeof("%s")];' % (istr, str)
-print "};"
-print
-print 'const struct FIELD_STRINGS FIELD_STRINGS = {'
-print ' "",'
+ print(' const char FIELD_STRINGS_%s[sizeof("%s")];' % (istr, str))
+print("};")
+print()
+print('const struct FIELD_STRINGS FIELD_STRINGS = {')
+print(' "",')
for str in strings:
- print ' "%s",'% str
-print "};"
-print 'const char * const FIELD_STRINGPOOL = (const char * const) &FIELD_STRINGS;'
-print
-print "/* This is an array of offsets into FIELD_STRINGPOOL */"
-print "const uint16_t FIELD_NAME[] = {"
-print " offsetof(struct FIELD_STRINGS, FIELD_STRINGS_NULL),"
+ print(' "%s",'% str)
+print("};")
+print('const char * const FIELD_STRINGPOOL = (const char * const) &FIELD_STRINGS;')
+print()
+print("/* This is an array of offsets into FIELD_STRINGPOOL */")
+print("const uint16_t FIELD_NAME[] = {")
+print(" offsetof(struct FIELD_STRINGS, FIELD_STRINGS_NULL),")
index = 1
for i in range(256):
if i in fields:
name, fnames = fields[i]
iname = name.replace("-", "_");
- print ' offsetof(struct FIELD_STRINGS, FIELD_STRINGS_%s), /* %d */' % (iname, index)
+ print(' offsetof(struct FIELD_STRINGS, FIELD_STRINGS_%s), /* %d */' % (iname, index))
index += 1
-print "};"
+print("};")
-print "/* This is an array of offsets into FIELD_STRINGPOOL */"
-print "const uint16_t FIELD_FIELDS[] = {"
-print " offsetof(struct FIELD_STRINGS, FIELD_STRINGS_NULL),"
+print("/* This is an array of offsets into FIELD_STRINGPOOL */")
+print("const uint16_t FIELD_FIELDS[] = {")
+print(" offsetof(struct FIELD_STRINGS, FIELD_STRINGS_NULL),")
index = 1
for i in range(256):
if i in fields:
@@ -105,11 +106,11 @@ for i in range(256):
if fnames:
for f in fnames:
ifname = f.replace("-", "_");
- print ' offsetof(struct FIELD_STRINGS, FIELD_STRINGS_%s), /* %d (%s) */' % (ifname, index, name)
+ print(' offsetof(struct FIELD_STRINGS, FIELD_STRINGS_%s), /* %d (%s) */' % (ifname, index, name))
index += 1
-print "};"
+print("};")
-print "const pn_fields_t FIELDS[] = {"
+print("const pn_fields_t FIELDS[] = {")
name_count = 1
field_count = 1
@@ -124,21 +125,21 @@ for i in range(field_min, field_max+1):
if i in fields:
name, fnames = fields[i]
if fnames:
- print ' {%d, %d, %d}, /* %d (%s) */' % (name_count, field_count, len(fnames), i, name)
+ print(' {%d, %d, %d}, /* %d (%s) */' % (name_count, field_count, len(fnames), i, name))
field_count += len(fnames)
else:
- print ' {%d, 0, 0}, /* %d (%s) */' % (name_count, i, name)
+ print(' {%d, 0, 0}, /* %d (%s) */' % (name_count, i, name))
name_count += 1
if i>field_max: field_max = i
if i<field_min: field_min = i
else:
- print ' {0, 0, 0}, /* %d */' % i
-
-print "};"
-print
-print 'const unsigned char FIELD_MIN = %d;' % field_min
-print 'const unsigned char FIELD_MAX = %d;' % field_max
-print
-print "#endif"
-print
-print "#endif /* protocol.h */"
+ print(' {0, 0, 0}, /* %d */' % i)
+
+print("};")
+print()
+print('const unsigned char FIELD_MIN = %d;' % field_min)
+print('const unsigned char FIELD_MAX = %d;' % field_max)
+print()
+print("#endif")
+print()
+print("#endif /* protocol.h */")
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[4/5] qpid-proton git commit: PROTON-490: port mllib document parser
to Python 3
Posted by kg...@apache.org.
PROTON-490: port mllib document parser to Python 3
Ported from the original patch supplied by Mickael Maison. Uses the
six compatibility library.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/5d7a4586
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/5d7a4586
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/5d7a4586
Branch: refs/heads/kgiusti-python3
Commit: 5d7a458635eb55167e33875e040b8147230c4c1b
Parents: 979471f
Author: Ken Giusti <kg...@apache.org>
Authored: Mon Apr 20 11:55:27 2015 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Mon Apr 20 13:04:56 2015 -0400
----------------------------------------------------------------------
proton-c/mllib/__init__.py | 23 ++++-------------------
proton-c/mllib/dom.py | 7 ++++---
proton-c/mllib/parsers.py | 37 ++-----------------------------------
proton-c/mllib/transforms.py | 2 +-
4 files changed, 11 insertions(+), 58 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7a4586/proton-c/mllib/__init__.py
----------------------------------------------------------------------
diff --git a/proton-c/mllib/__init__.py b/proton-c/mllib/__init__.py
index c6fccf1..9e78a87 100644
--- a/proton-c/mllib/__init__.py
+++ b/proton-c/mllib/__init__.py
@@ -18,8 +18,7 @@
#
"""
-This module provides document parsing and transformation utilities for
-both SGML and XML.
+This module provides document parsing and transformation utilities for XML.
"""
from __future__ import absolute_import
@@ -28,7 +27,8 @@ import os, sys
import xml.sax, types
from xml.sax.handler import ErrorHandler
from xml.sax.xmlreader import InputSource
-from cStringIO import StringIO
+import six
+from six.moves import cStringIO as StringIO
from . import dom
from . import transforms
@@ -37,26 +37,11 @@ from . import parsers
def transform(node, *args):
result = node
for t in args:
- if isinstance(t, type):
+ if isinstance(t, six.class_types):
t = t()
result = result.dispatch(t)
return result
-def sgml_parse(source):
- if isinstance(source, basestring):
- source = StringIO(source)
- fname = "<string>"
- elif hasattr(source, "name"):
- fname = source.name
- p = parsers.SGMLParser()
- num = 1
- for line in source:
- p.feed(line)
- p.parser.line(fname, num, None)
- num += 1
- p.close()
- return p.parser.tree
-
class Resolver:
def __init__(self, path):
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7a4586/proton-c/mllib/dom.py
----------------------------------------------------------------------
diff --git a/proton-c/mllib/dom.py b/proton-c/mllib/dom.py
index 4cbac26..b6ca27d 100644
--- a/proton-c/mllib/dom.py
+++ b/proton-c/mllib/dom.py
@@ -26,6 +26,7 @@ from __future__ import generators
from __future__ import nested_scopes
from __future__ import absolute_import
+import six
class Container:
@@ -178,7 +179,7 @@ class Leaf(Component, Dispatcher):
base = None
def __init__(self, data):
- assert isinstance(data, basestring)
+ assert isinstance(data, six.string_types)
self.data = data
class Data(Leaf):
@@ -268,7 +269,7 @@ class Values(View):
yield value
def flatten_path(path):
- if isinstance(path, basestring):
+ if isinstance(path, six.string_types):
for part in path.split("/"):
yield part
elif callable(path):
@@ -291,7 +292,7 @@ class Query(View):
select = Query
pred = p
source = query
- elif isinstance(p, basestring):
+ elif isinstance(p, six.string_types):
if p[0] == "@":
select = Values
pred = lambda x, n=p[1:]: x[0] == n
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7a4586/proton-c/mllib/parsers.py
----------------------------------------------------------------------
diff --git a/proton-c/mllib/parsers.py b/proton-c/mllib/parsers.py
index e71018d..72d44ab 100644
--- a/proton-c/mllib/parsers.py
+++ b/proton-c/mllib/parsers.py
@@ -18,11 +18,11 @@
#
"""
-Parsers for SGML and XML to dom.
+Parsers for XML to dom.
"""
from __future__ import absolute_import
-import sgmllib, xml.sax.handler
+import xml.sax.handler
from .dom import *
class Parser:
@@ -74,39 +74,6 @@ class Parser:
self.node = self.node.parent
-class SGMLParser(sgmllib.SGMLParser):
-
- def __init__(self, entitydefs = None):
- sgmllib.SGMLParser.__init__(self)
- if entitydefs == None:
- self.entitydefs = {}
- else:
- self.entitydefs = entitydefs
- self.parser = Parser()
-
- def unknown_starttag(self, name, attrs):
- self.parser.start(name, attrs)
-
- def handle_data(self, data):
- self.parser.data(data)
-
- def handle_comment(self, comment):
- self.parser.comment(comment)
-
- def unknown_entityref(self, ref):
- self.parser.entity(ref)
-
- def unknown_charref(self, ref):
- self.parser.character(ref)
-
- def unknown_endtag(self, name):
- self.parser.end(name)
-
- def close(self):
- sgmllib.SGMLParser.close(self)
- self.parser.balance()
- assert self.parser.node == self.parser.tree
-
class XMLParser(xml.sax.handler.ContentHandler):
def __init__(self):
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7a4586/proton-c/mllib/transforms.py
----------------------------------------------------------------------
diff --git a/proton-c/mllib/transforms.py b/proton-c/mllib/transforms.py
index 383add3..43e9ef2 100644
--- a/proton-c/mllib/transforms.py
+++ b/proton-c/mllib/transforms.py
@@ -23,7 +23,7 @@ Useful transforms for dom objects.
from __future__ import absolute_import
from . import dom
-from cStringIO import StringIO
+from six.moves import cStringIO as StringIO
class Visitor:
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[5/5] qpid-proton git commit: PROTON-490: port mllib document parser
to Python 3
Posted by kg...@apache.org.
PROTON-490: port mllib document parser to Python 3
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/e87a6d31
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/e87a6d31
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/e87a6d31
Branch: refs/heads/kgiusti-python3
Commit: e87a6d313ecf2f468852de83126b1fdd7924b737
Parents: 903c724 5d7a458
Author: Ken Giusti <kg...@apache.org>
Authored: Wed Apr 22 10:55:12 2015 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Wed Apr 22 10:55:12 2015 -0400
----------------------------------------------------------------------
proton-c/mllib/__init__.py | 27 ++++++++-------------------
proton-c/mllib/dom.py | 7 ++++---
proton-c/mllib/parsers.py | 37 ++-----------------------------------
proton-c/mllib/transforms.py | 2 +-
4 files changed, 15 insertions(+), 58 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e87a6d31/proton-c/mllib/__init__.py
----------------------------------------------------------------------
diff --cc proton-c/mllib/__init__.py
index c6fccf1,9e78a87..e506060
--- a/proton-c/mllib/__init__.py
+++ b/proton-c/mllib/__init__.py
@@@ -28,10 -27,11 +27,15 @@@ import os, sy
import xml.sax, types
from xml.sax.handler import ErrorHandler
from xml.sax.xmlreader import InputSource
- from cStringIO import StringIO
+ import six
+ from six.moves import cStringIO as StringIO
+
+ from . import dom
+ from . import transforms
++from . import parsers
+
+from . import dom
+from . import transforms
from . import parsers
def transform(node, *args):
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[3/5] qpid-proton git commit: PROTON-490: futurize the python code
under the test directory
Posted by kg...@apache.org.
PROTON-490: futurize the python code under the test directory
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/979471f5
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/979471f5
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/979471f5
Branch: refs/heads/kgiusti-python3
Commit: 979471f5ee355b3eca43f8cf176ebc7e241ab603
Parents: aae1d20
Author: Ken Giusti <kg...@apache.org>
Authored: Fri Apr 17 09:39:51 2015 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Mon Apr 20 12:46:47 2015 -0400
----------------------------------------------------------------------
tests/python/proton_tests/codec.py | 87 +++++++++++++++--------------
tests/python/proton_tests/common.py | 24 +++++++-
tests/python/proton_tests/engine.py | 8 ++-
tests/python/proton_tests/interop.py | 21 +++----
tests/python/proton_tests/message.py | 3 +-
tests/python/proton_tests/messenger.py | 9 ++-
tests/python/proton_tests/reactor.py | 3 +-
tests/python/proton_tests/sasl.py | 6 +-
tests/python/proton_tests/soak.py | 3 +-
tests/python/proton_tests/ssl.py | 11 ++--
tests/python/proton_tests/transport.py | 9 ++-
tests/python/proton_tests/url.py | 3 +-
tests/smoke/recv.py | 3 +-
tests/smoke/send.py | 5 +-
tests/tools/apps/python/msgr-recv.py | 1 +
tests/tools/apps/python/msgr-send.py | 1 +
16 files changed, 121 insertions(+), 76 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/979471f5/tests/python/proton_tests/codec.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/codec.py b/tests/python/proton_tests/codec.py
index 81bb4de..e8893cf 100644
--- a/tests/python/proton_tests/codec.py
+++ b/tests/python/proton_tests/codec.py
@@ -17,7 +17,8 @@
# under the License.
#
-import os, common, sys
+import os, sys
+from . import common
from proton import *
try:
from uuid import uuid4
@@ -36,58 +37,58 @@ class Test(common.Test):
class DataTest(Test):
def testTopLevelNext(self):
- assert self.data.next() is None
+ assert next(self.data) is None
self.data.put_null()
self.data.put_bool(False)
self.data.put_int(0)
- assert self.data.next() is None
+ assert next(self.data) is None
self.data.rewind()
- assert self.data.next() == Data.NULL
- assert self.data.next() == Data.BOOL
- assert self.data.next() == Data.INT
- assert self.data.next() is None
+ assert next(self.data) == Data.NULL
+ assert next(self.data) == Data.BOOL
+ assert next(self.data) == Data.INT
+ assert next(self.data) is None
def testNestedNext(self):
- assert self.data.next() is None
+ assert next(self.data) is None
self.data.put_null()
- assert self.data.next() is None
+ assert next(self.data) is None
self.data.put_list()
- assert self.data.next() is None
+ assert next(self.data) is None
self.data.put_bool(False)
- assert self.data.next() is None
+ assert next(self.data) is None
self.data.rewind()
- assert self.data.next() is Data.NULL
- assert self.data.next() is Data.LIST
+ assert next(self.data) is Data.NULL
+ assert next(self.data) is Data.LIST
self.data.enter()
- assert self.data.next() is None
+ assert next(self.data) is None
self.data.put_ubyte(0)
- assert self.data.next() is None
+ assert next(self.data) is None
self.data.put_uint(0)
- assert self.data.next() is None
+ assert next(self.data) is None
self.data.put_int(0)
- assert self.data.next() is None
+ assert next(self.data) is None
self.data.exit()
- assert self.data.next() is Data.BOOL
- assert self.data.next() is None
+ assert next(self.data) is Data.BOOL
+ assert next(self.data) is None
self.data.rewind()
- assert self.data.next() is Data.NULL
- assert self.data.next() is Data.LIST
+ assert next(self.data) is Data.NULL
+ assert next(self.data) is Data.LIST
assert self.data.enter()
- assert self.data.next() is Data.UBYTE
- assert self.data.next() is Data.UINT
- assert self.data.next() is Data.INT
- assert self.data.next() is None
+ assert next(self.data) is Data.UBYTE
+ assert next(self.data) is Data.UINT
+ assert next(self.data) is Data.INT
+ assert next(self.data) is None
assert self.data.exit()
- assert self.data.next() is Data.BOOL
- assert self.data.next() is None
+ assert next(self.data) is Data.BOOL
+ assert next(self.data) is None
def testEnterExit(self):
- assert self.data.next() is None
+ assert next(self.data) is None
assert not self.data.enter()
self.data.put_list()
assert self.data.enter()
- assert self.data.next() is None
+ assert next(self.data) is None
self.data.put_list()
assert self.data.enter()
self.data.put_list()
@@ -100,19 +101,19 @@ class DataTest(Test):
assert self.data.get_list() == 1
assert not self.data.exit()
assert self.data.get_list() == 1
- assert self.data.next() is None
+ assert next(self.data) is None
self.data.rewind()
- assert self.data.next() is Data.LIST
+ assert next(self.data) is Data.LIST
assert self.data.get_list() == 1
assert self.data.enter()
- assert self.data.next() is Data.LIST
+ assert next(self.data) is Data.LIST
assert self.data.get_list() == 1
assert self.data.enter()
- assert self.data.next() is Data.LIST
+ assert next(self.data) is Data.LIST
assert self.data.get_list() == 0
assert self.data.enter()
- assert self.data.next() is None
+ assert next(self.data) is None
assert self.data.exit()
assert self.data.get_list() == 0
assert self.data.exit()
@@ -126,7 +127,7 @@ class DataTest(Test):
"""More informative exception from putters, include bad value"""
try:
putter(v)
- except Exception, e:
+ except Exception:
etype, value, trace = sys.exc_info()
raise etype, "%s(%r): %s" % (putter.__name__, v, value), trace
return putter
@@ -168,7 +169,7 @@ class DataTest(Test):
self.put(putter, v)
self.data.exit()
self.data.rewind()
- assert self.data.next() == Data.ARRAY
+ assert next(self.data) == Data.ARRAY
count, described, type = self.data.get_array()
assert count == len(values), count
if dtype is None:
@@ -178,17 +179,17 @@ class DataTest(Test):
assert type == aTYPE, type
assert self.data.enter()
if described:
- assert self.data.next() == dTYPE
+ assert next(self.data) == dTYPE
getter = getattr(self.data, "get_%s" % dtype)
gotten = getter()
assert gotten == descriptor, gotten
if values:
getter = getattr(self.data, "get_%s" % atype)
for v in values:
- assert self.data.next() == aTYPE
+ assert next(self.data) == aTYPE
gotten = getter()
assert gotten == v, gotten
- assert self.data.next() is None
+ assert next(self.data) is None
assert self.data.exit()
def testStringArray(self):
@@ -230,7 +231,7 @@ class DataTest(Test):
self.data.rewind()
for v in values:
- vtype = self.data.next()
+ vtype = next(self.data)
assert vtype == ntype, vtype
gotten = getter()
assert eq(gotten, v), (gotten, v)
@@ -245,7 +246,7 @@ class DataTest(Test):
cgetter = getattr(copy, "get_%s" % dtype)
for v in values:
- vtype = copy.next()
+ vtype = next(copy)
assert vtype == ntype, vtype
gotten = cgetter()
assert eq(gotten, v), (gotten, v)
@@ -345,7 +346,7 @@ class DataTest(Test):
data = Data()
data.decode(enc)
data.rewind()
- assert data.next()
+ assert next(data)
copy = data.get_object()
assert copy == obj, (copy, obj)
@@ -355,7 +356,7 @@ class DataTest(Test):
symbol("list"): [1, 2, 3, 4]}
self.data.put_object(obj)
self.data.rewind()
- self.data.next()
+ next(self.data)
self.data.enter()
self.data.narrow()
assert self.data.lookup("pi")
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/979471f5/tests/python/proton_tests/common.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/common.py b/tests/python/proton_tests/common.py
index 1b8dbdb..585ea02 100644
--- a/tests/python/proton_tests/common.py
+++ b/tests/python/proton_tests/common.py
@@ -27,6 +27,27 @@ from proton import Connection, Transport, SASL, Endpoint, Delivery, SSL
from proton.reactor import Container
from proton.handlers import CHandshaker, CFlowController
+if sys.version_info[0] == 2 and sys.version_info[1] < 6:
+ # this is for compatibility, apparently the version of jython we
+ # use doesn't have the next() builtin.
+ # we should remove this when we upgrade to a python 2.6+ compatible version
+ # of jython
+ #_DEF = object() This causes the test loader to fail (why?)
+ class _dummy(): pass
+ _DEF = _dummy
+
+ def next(iter, default=_DEF):
+ try:
+ return iter.next()
+ except StopIteration:
+ if default is _DEF:
+ raise
+ else:
+ return default
+ # I may goto hell for this:
+ import __builtin__
+ __builtin__.__dict__['next'] = next
+
def free_tcp_ports(count=1):
""" return a list of 'count' TCP ports that are free to used (ie. unbound)
@@ -224,7 +245,8 @@ class MessengerApp(object):
cmd.insert(0, foundfile)
cmd.insert(0, sys.executable)
self._process = Popen(cmd, stdout=PIPE, stderr=STDOUT, bufsize=4096)
- except OSError, e:
+ except OSError:
+ e = sys.exc_info()[1]
print("ERROR: '%s'" % e)
assert False, "Unable to execute command '%s', is it in your PATH?" % cmd[0]
self._ready() # wait for it to initialize
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/979471f5/tests/python/proton_tests/engine.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/engine.py b/tests/python/proton_tests/engine.py
index 99125d9..7835792 100644
--- a/tests/python/proton_tests/engine.py
+++ b/tests/python/proton_tests/engine.py
@@ -1,3 +1,4 @@
+from __future__ import absolute_import
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -17,10 +18,11 @@
# under the License.
#
-import os, common, gc
+import os, gc
+from . import common
from time import time, sleep
from proton import *
-from common import pump
+from .common import pump
from proton.reactor import Reactor
# older versions of gc do not provide the garbage list
@@ -1836,7 +1838,7 @@ class PipelineTest(Test):
assert rcv.queued == 0, rcv.queued
import sys
-from common import Skipped
+from .common import Skipped
class ServerTest(Test):
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/979471f5/tests/python/proton_tests/interop.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/interop.py b/tests/python/proton_tests/interop.py
index baf998d..1ef92dd 100644
--- a/tests/python/proton_tests/interop.py
+++ b/tests/python/proton_tests/interop.py
@@ -18,7 +18,8 @@
#
from proton import *
-import os, common
+import os
+from . import common
def find_test_interop_dir():
@@ -70,7 +71,7 @@ class InteropTest(common.Test):
self.decode_data(body)
def assert_next(self, type, value):
- next_type = self.data.next()
+ next_type = next(self.data)
assert next_type == type, "Type mismatch: %s != %s"%(
Data.type_names[next_type], Data.type_names[type])
next_value = self.data.get_object()
@@ -79,7 +80,7 @@ class InteropTest(common.Test):
def test_message(self):
self.decode_message_file("message")
self.assert_next(Data.STRING, "hello")
- assert self.data.next() is None
+ assert next(self.data) is None
def test_primitives(self):
self.decode_data_file("primitives")
@@ -94,7 +95,7 @@ class InteropTest(common.Test):
self.assert_next(Data.LONG, -12345)
self.assert_next(Data.FLOAT, 0.125)
self.assert_next(Data.DOUBLE, 0.125)
- assert self.data.next() is None
+ assert next(self.data) is None
def test_strings(self):
self.decode_data_file("strings")
@@ -104,20 +105,20 @@ class InteropTest(common.Test):
self.assert_next(Data.BINARY, "")
self.assert_next(Data.STRING, "")
self.assert_next(Data.SYMBOL, "")
- assert self.data.next() is None
+ assert next(self.data) is None
def test_described(self):
self.decode_data_file("described")
self.assert_next(Data.DESCRIBED, Described("foo-descriptor", "foo-value"))
self.data.exit()
- assert self.data.next() == Data.DESCRIBED
+ assert next(self.data) == Data.DESCRIBED
self.data.enter()
self.assert_next(Data.INT, 12)
self.assert_next(Data.INT, 13)
self.data.exit()
- assert self.data.next() is None
+ assert next(self.data) is None
def test_described_array(self):
self.decode_data_file("described_array")
@@ -128,17 +129,17 @@ class InteropTest(common.Test):
self.assert_next(Data.ARRAY, Array(UNDESCRIBED, Data.INT, *range(0,100)))
self.assert_next(Data.ARRAY, Array(UNDESCRIBED, Data.STRING, *["a", "b", "c"]))
self.assert_next(Data.ARRAY, Array(UNDESCRIBED, Data.INT))
- assert self.data.next() is None
+ assert next(self.data) is None
def test_lists(self):
self.decode_data_file("lists")
self.assert_next(Data.LIST, [32, "foo", True])
self.assert_next(Data.LIST, [])
- assert self.data.next() is None
+ assert next(self.data) is None
def test_maps(self):
self.decode_data_file("maps")
self.assert_next(Data.MAP, {"one":1, "two":2, "three":3 })
self.assert_next(Data.MAP, {1:"one", 2:"two", 3:"three"})
self.assert_next(Data.MAP, {})
- assert self.data.next() is None
+ assert next(self.data) is None
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/979471f5/tests/python/proton_tests/message.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/message.py b/tests/python/proton_tests/message.py
index 6bf94fe..3366366 100644
--- a/tests/python/proton_tests/message.py
+++ b/tests/python/proton_tests/message.py
@@ -17,7 +17,8 @@
# under the License.
#
-import os, common
+import os
+from . import common
from proton import *
try:
from uuid import uuid4
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/979471f5/tests/python/proton_tests/messenger.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/messenger.py b/tests/python/proton_tests/messenger.py
index c7c7dd3..03a1b6b 100644
--- a/tests/python/proton_tests/messenger.py
+++ b/tests/python/proton_tests/messenger.py
@@ -1,3 +1,4 @@
+from __future__ import absolute_import
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -17,11 +18,12 @@
# under the License.
#
-import os, common, sys, traceback
+import os, sys, traceback
+from . import common
from proton import *
from threading import Thread, Event
from time import sleep, time
-from common import Skipped
+from .common import Skipped
class Test(common.Test):
@@ -180,7 +182,8 @@ class MessengerTest(Test):
try:
self.client.put(msg)
assert False, "Expecting MessengerException"
- except MessengerException, exc:
+ except MessengerException:
+ exc = sys.exc_info()[1]
err = str(exc)
assert "unable to send to address: totally-bogus-address" in err, err
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/979471f5/tests/python/proton_tests/reactor.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/reactor.py b/tests/python/proton_tests/reactor.py
index 4e660a5..6afee30 100644
--- a/tests/python/proton_tests/reactor.py
+++ b/tests/python/proton_tests/reactor.py
@@ -1,3 +1,4 @@
+from __future__ import absolute_import
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -17,7 +18,7 @@
# under the License.
#
-from common import Test
+from .common import Test
from proton.reactor import Reactor
class Barf(Exception):
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/979471f5/tests/python/proton_tests/sasl.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/sasl.py b/tests/python/proton_tests/sasl.py
index a14a0db..0d6761f 100644
--- a/tests/python/proton_tests/sasl.py
+++ b/tests/python/proton_tests/sasl.py
@@ -1,3 +1,4 @@
+from __future__ import absolute_import
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -17,9 +18,10 @@
# under the License.
#
-import os, common
+import os
+from . import common
from proton import *
-from common import pump
+from .common import pump
class Test(common.Test):
pass
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/979471f5/tests/python/proton_tests/soak.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/soak.py b/tests/python/proton_tests/soak.py
index 9e5ceab..0a6e693 100644
--- a/tests/python/proton_tests/soak.py
+++ b/tests/python/proton_tests/soak.py
@@ -1,3 +1,4 @@
+from __future__ import absolute_import
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -18,7 +19,7 @@
#
import os
import sys
-from common import Test, Skipped, free_tcp_ports, \
+from .common import Test, Skipped, free_tcp_ports, \
MessengerReceiverC, MessengerSenderC, \
MessengerReceiverValgrind, MessengerSenderValgrind, \
MessengerReceiverPython, MessengerSenderPython, \
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/979471f5/tests/python/proton_tests/ssl.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/ssl.py b/tests/python/proton_tests/ssl.py
index f5fae3f..fd5aaf1 100644
--- a/tests/python/proton_tests/ssl.py
+++ b/tests/python/proton_tests/ssl.py
@@ -1,3 +1,4 @@
+from __future__ import absolute_import
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -17,13 +18,14 @@
# under the License.
#
-import os, common
+import os
+from . import common
import random
import string
import subprocess
from proton import *
-from common import Skipped, pump
+from .common import Skipped, pump
def _testpath(file):
@@ -791,7 +793,7 @@ class SslTest(common.Test):
try:
ssl3 = SSL(transport, self.server_domain)
assert False, "Expected error did not occur!"
- except SSLException, e:
+ except SSLException:
pass
class MessengerSSLTests(common.Test):
@@ -834,7 +836,8 @@ class MessengerSSLTests(common.Test):
self.server.subscribe("amqps://~0.0.0.0:12345")
if exception is not None:
assert False, "expected failure did not occur"
- except MessengerException, e:
+ except MessengerException:
+ e = sys.exc_info()[1]
if exception:
assert exception in str(e), str(e)
else:
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/979471f5/tests/python/proton_tests/transport.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/transport.py b/tests/python/proton_tests/transport.py
index dcf7636..512d816 100644
--- a/tests/python/proton_tests/transport.py
+++ b/tests/python/proton_tests/transport.py
@@ -17,7 +17,8 @@
# under the License.
#
-import os, common
+import os
+from . import common
from proton import *
@@ -119,7 +120,8 @@ class TransportTest(Test):
assert n > 0, n
try:
self.transport.close_head()
- except TransportException, e:
+ except TransportException:
+ e = sys.exc_info()[1]
assert "aborted" in str(e), str(e)
n = self.transport.pending()
assert n < 0, n
@@ -129,7 +131,8 @@ class TransportTest(Test):
assert n > 0, n
try:
self.transport.close_tail()
- except TransportException, e:
+ except TransportException:
+ e = sys.exc_info()[1]
assert "aborted" in str(e), str(e)
n = self.transport.capacity()
assert n < 0, n
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/979471f5/tests/python/proton_tests/url.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/url.py b/tests/python/proton_tests/url.py
index 77a16ff..40a257c 100644
--- a/tests/python/proton_tests/url.py
+++ b/tests/python/proton_tests/url.py
@@ -1,3 +1,4 @@
+from __future__ import absolute_import
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -18,7 +19,7 @@
#
-import common
+from . import common
from proton import Url
class UrlTest(common.Test):
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/979471f5/tests/smoke/recv.py
----------------------------------------------------------------------
diff --git a/tests/smoke/recv.py b/tests/smoke/recv.py
index 3b2b0e5..e6aa2b6 100755
--- a/tests/smoke/recv.py
+++ b/tests/smoke/recv.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from __future__ import print_function
import sys
from proton import *
@@ -16,7 +17,7 @@ messenger.start()
while True:
messenger.recv()
messenger.get(message)
- print "Got: %s" % message
+ print("Got: %s" % message)
messenger.accept()
messenger.stop()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/979471f5/tests/smoke/send.py
----------------------------------------------------------------------
diff --git a/tests/smoke/send.py b/tests/smoke/send.py
index 1aed9c8..7daee01 100755
--- a/tests/smoke/send.py
+++ b/tests/smoke/send.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from __future__ import print_function
import sys
from proton import *
@@ -17,7 +18,7 @@ message.body = u"Hello World!"
messenger.start()
tracker = messenger.put(message)
-print "Put: %s" % message
+print("Put: %s" % message)
messenger.send()
-print "Status: %s" % messenger.status(tracker)
+print("Status: %s" % messenger.status(tracker))
messenger.stop()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/979471f5/tests/tools/apps/python/msgr-recv.py
----------------------------------------------------------------------
diff --git a/tests/tools/apps/python/msgr-recv.py b/tests/tools/apps/python/msgr-recv.py
index 73c2a3a..079c871 100755
--- a/tests/tools/apps/python/msgr-recv.py
+++ b/tests/tools/apps/python/msgr-recv.py
@@ -18,6 +18,7 @@
# specific language governing permissions and limitations
# under the License.
#
+from __future__ import print_function
import sys, optparse, time
import logging
from proton import *
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/979471f5/tests/tools/apps/python/msgr-send.py
----------------------------------------------------------------------
diff --git a/tests/tools/apps/python/msgr-send.py b/tests/tools/apps/python/msgr-send.py
index 872122b..a2f67c5 100755
--- a/tests/tools/apps/python/msgr-send.py
+++ b/tests/tools/apps/python/msgr-send.py
@@ -18,6 +18,7 @@
# specific language governing permissions and limitations
# under the License.
#
+from __future__ import print_function
import sys, optparse, time
import logging
from proton import *
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[2/5] qpid-proton git commit: PROTON-490: futurize examples
Posted by kg...@apache.org.
PROTON-490: futurize examples
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/aae1d20a
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/aae1d20a
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/aae1d20a
Branch: refs/heads/kgiusti-python3
Commit: aae1d20a42dcaded08b8daec4cf43bd5e1fde970
Parents: 677729a
Author: Ken Giusti <kg...@apache.org>
Authored: Thu Apr 16 14:57:08 2015 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Mon Apr 20 12:46:20 2015 -0400
----------------------------------------------------------------------
examples/python/abstract_server.py | 3 ++-
examples/python/client.py | 3 ++-
examples/python/client_http.py | 3 ++-
examples/python/db_ctrl.py | 7 ++++---
examples/python/db_recv.py | 3 ++-
examples/python/db_send.py | 11 ++++++-----
examples/python/direct_recv.py | 3 ++-
examples/python/direct_send.py | 3 ++-
examples/python/helloworld.py | 3 ++-
examples/python/helloworld_blocking.py | 3 ++-
examples/python/helloworld_direct.py | 3 ++-
examples/python/helloworld_direct_tornado.py | 3 ++-
examples/python/helloworld_tornado.py | 3 ++-
examples/python/messenger/async.py | 3 ++-
examples/python/messenger/client.py | 7 ++++---
examples/python/messenger/recv.py | 7 ++++---
examples/python/messenger/recv_async.py | 11 ++++++-----
examples/python/messenger/send.py | 3 ++-
examples/python/messenger/send_async.py | 9 +++++----
examples/python/messenger/server.py | 5 +++--
examples/python/proton_server.py | 3 ++-
examples/python/queue_browser.py | 3 ++-
examples/python/reactor/cat.py | 3 ++-
examples/python/reactor/count-randomly.py | 9 +++++----
examples/python/reactor/counter.py | 7 ++++---
examples/python/reactor/delegates.py | 5 +++--
examples/python/reactor/echo.py | 5 +++--
examples/python/reactor/global-logger.py | 9 +++++----
examples/python/reactor/goodbye-world.py | 5 +++--
examples/python/reactor/handlers.py | 7 ++++---
examples/python/reactor/hello-world.py | 3 ++-
examples/python/reactor/reactor-logger.py | 7 ++++---
examples/python/reactor/recv.py | 3 ++-
examples/python/reactor/scheduling.py | 7 ++++---
examples/python/reactor/tornado-hello-world.py | 3 ++-
examples/python/reactor/unhandled.py | 3 ++-
examples/python/recurring_timer.py | 5 +++--
examples/python/recurring_timer_tornado.py | 5 +++--
examples/python/selected_recv.py | 3 ++-
examples/python/server.py | 5 +++--
examples/python/server_direct.py | 7 ++++---
examples/python/server_tx.py | 5 +++--
examples/python/simple_recv.py | 3 ++-
examples/python/simple_send.py | 3 ++-
examples/python/sync_client.py | 3 ++-
examples/python/tx_recv.py | 3 ++-
examples/python/tx_recv_interactive.py | 11 ++++++-----
examples/python/tx_send.py | 3 ++-
48 files changed, 141 insertions(+), 93 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/abstract_server.py
----------------------------------------------------------------------
diff --git a/examples/python/abstract_server.py b/examples/python/abstract_server.py
index 2d0de32..fed7fb2 100755
--- a/examples/python/abstract_server.py
+++ b/examples/python/abstract_server.py
@@ -18,6 +18,7 @@
# under the License.
#
+from __future__ import print_function
from proton_server import Server
class Application(Server):
@@ -27,7 +28,7 @@ class Application(Server):
def on_request(self, request, reply_to):
response = request.upper()
self.send(response, reply_to)
- print "Request from: %s" % reply_to
+ print("Request from: %s" % reply_to)
try:
Application("localhost:5672", "examples").run()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/client.py
----------------------------------------------------------------------
diff --git a/examples/python/client.py b/examples/python/client.py
index a116175..18dc81a 100755
--- a/examples/python/client.py
+++ b/examples/python/client.py
@@ -18,6 +18,7 @@
# under the License.
#
+from __future__ import print_function
import optparse
from proton import Message
from proton.handlers import MessagingHandler
@@ -43,7 +44,7 @@ class Client(MessagingHandler):
self.next_request()
def on_message(self, event):
- print "%s => %s" % (self.requests.pop(0), event.message.body)
+ print("%s => %s" % (self.requests.pop(0), event.message.body))
if self.requests:
self.next_request()
else:
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/client_http.py
----------------------------------------------------------------------
diff --git a/examples/python/client_http.py b/examples/python/client_http.py
index cd0d63f..bf65639 100755
--- a/examples/python/client_http.py
+++ b/examples/python/client_http.py
@@ -18,6 +18,7 @@
# under the License.
#
+from __future__ import print_function
import tornado.ioloop
import tornado.web
from proton import Message
@@ -51,7 +52,7 @@ class Client(MessagingHandler):
def on_message(self, event):
if self.sent:
request, handler = self.sent.pop(0)
- print "%s => %s" % (request, event.message.body)
+ print("%s => %s" % (request, event.message.body))
handler(event.message.body)
self.do_request()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/db_ctrl.py
----------------------------------------------------------------------
diff --git a/examples/python/db_ctrl.py b/examples/python/db_ctrl.py
index b28e0eb..04770ce 100755
--- a/examples/python/db_ctrl.py
+++ b/examples/python/db_ctrl.py
@@ -18,11 +18,12 @@
# under the License.
#
+from __future__ import print_function
import sqlite3
import sys
if len(sys.argv) < 3:
- print "Usage: %s [init|insert|list] db" % sys.argv[0]
+ print("Usage: %s [init|insert|list] db" % sys.argv[0])
else:
conn = sqlite3.connect(sys.argv[2])
with conn:
@@ -35,7 +36,7 @@ else:
cursor.execute("SELECT * FROM records")
rows = cursor.fetchall()
for r in rows:
- print r
+ print(r)
elif sys.argv[1] == "insert":
while True:
l = sys.stdin.readline()
@@ -43,4 +44,4 @@ else:
conn.execute("INSERT INTO records(description) VALUES (?)", (l.rstrip(),))
conn.commit()
else:
- print "Unrecognised command: %s" % sys.argv[1]
+ print("Unrecognised command: %s" % sys.argv[1])
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/db_recv.py
----------------------------------------------------------------------
diff --git a/examples/python/db_recv.py b/examples/python/db_recv.py
index d8dd7bc..8c79049 100755
--- a/examples/python/db_recv.py
+++ b/examples/python/db_recv.py
@@ -18,6 +18,7 @@
# under the License.
#
+from __future__ import print_function
import optparse
from proton.handlers import MessagingHandler
from proton.reactor import ApplicationEvent, Container, EventInjector
@@ -58,7 +59,7 @@ class Recv(MessagingHandler):
self.received += 1
self.last_id = id
self.db.insert(id, event.message.body, ApplicationEvent("record_inserted", delivery=event.delivery))
- print "inserted message %s" % id
+ print("inserted message %s" % id)
else:
self.release(event.delivery)
else:
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/db_send.py
----------------------------------------------------------------------
diff --git a/examples/python/db_send.py b/examples/python/db_send.py
index 6464fa6..99558d5 100755
--- a/examples/python/db_send.py
+++ b/examples/python/db_send.py
@@ -18,6 +18,7 @@
# under the License.
#
+from __future__ import print_function
import optparse
import Queue
import time
@@ -49,7 +50,7 @@ class Send(MessagingHandler):
def on_records_loaded(self, event):
if self.records.empty():
if event.subject == self.load_count:
- print "Exhausted available data, waiting to recheck..."
+ print("Exhausted available data, waiting to recheck...")
# check for new data after 5 seconds
self.container.schedule(5, self)
else:
@@ -57,7 +58,7 @@ class Send(MessagingHandler):
def request_records(self):
if not self.records.full():
- print "loading records..."
+ print("loading records...")
self.load_count += 1
self.db.load(self.records, event=ApplicationEvent("records_loaded", link=self.sender, subject=self.load_count))
@@ -71,13 +72,13 @@ class Send(MessagingHandler):
id = record['id']
self.sender.send(Message(id=id, durable=True, body=record['description']), tag=str(id))
self.sent += 1
- print "sent message %s" % id
+ print("sent message %s" % id)
self.request_records()
def on_settled(self, event):
id = int(event.delivery.tag)
self.db.delete(id)
- print "settled message %s" % id
+ print("settled message %s" % id)
self.confirmed += 1
if self.confirmed == self.target:
event.connection.close()
@@ -88,7 +89,7 @@ class Send(MessagingHandler):
self.sent = self.confirmed
def on_timer_task(self, event):
- print "Rechecking for data..."
+ print("Rechecking for data...")
self.request_records()
parser = optparse.OptionParser(usage="usage: %prog [options]",
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/direct_recv.py
----------------------------------------------------------------------
diff --git a/examples/python/direct_recv.py b/examples/python/direct_recv.py
index 92f712c..1c6bf36 100755
--- a/examples/python/direct_recv.py
+++ b/examples/python/direct_recv.py
@@ -18,6 +18,7 @@
# under the License.
#
+from __future__ import print_function
import optparse
from proton.handlers import MessagingHandler
from proton.reactor import Container
@@ -37,7 +38,7 @@ class Recv(MessagingHandler):
# ignore duplicate message
return
if self.expected == 0 or self.received < self.expected:
- print event.message.body
+ print(event.message.body)
self.received += 1
if self.received == self.expected:
event.receiver.close()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/direct_send.py
----------------------------------------------------------------------
diff --git a/examples/python/direct_send.py b/examples/python/direct_send.py
index 0bfad17..f551e1e 100755
--- a/examples/python/direct_send.py
+++ b/examples/python/direct_send.py
@@ -18,6 +18,7 @@
# under the License.
#
+from __future__ import print_function
import optparse
from proton import Message
from proton.handlers import MessagingHandler
@@ -43,7 +44,7 @@ class Send(MessagingHandler):
def on_accepted(self, event):
self.confirmed += 1
if self.confirmed == self.total:
- print "all messages confirmed"
+ print("all messages confirmed")
event.connection.close()
self.acceptor.close()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/helloworld.py
----------------------------------------------------------------------
diff --git a/examples/python/helloworld.py b/examples/python/helloworld.py
index d741f5e..d73a4cb 100755
--- a/examples/python/helloworld.py
+++ b/examples/python/helloworld.py
@@ -18,6 +18,7 @@
# under the License.
#
+from __future__ import print_function
from proton import Message
from proton.handlers import MessagingHandler
from proton.reactor import Container
@@ -38,7 +39,7 @@ class HelloWorld(MessagingHandler):
event.sender.close()
def on_message(self, event):
- print event.message.body
+ print(event.message.body)
event.connection.close()
Container(HelloWorld("localhost:5672", "examples")).run()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/helloworld_blocking.py
----------------------------------------------------------------------
diff --git a/examples/python/helloworld_blocking.py b/examples/python/helloworld_blocking.py
index 62b6105..049f148 100755
--- a/examples/python/helloworld_blocking.py
+++ b/examples/python/helloworld_blocking.py
@@ -18,6 +18,7 @@
# under the License.
#
+from __future__ import print_function
from proton import Message
from proton.utils import BlockingConnection
from proton.handlers import IncomingMessageHandler
@@ -27,7 +28,7 @@ receiver = conn.create_receiver("examples")
sender = conn.create_sender("examples")
sender.send(Message(body=u"Hello World!"));
msg = receiver.receive(timeout=30)
-print msg.body
+print(msg.body)
receiver.accept()
conn.close()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/helloworld_direct.py
----------------------------------------------------------------------
diff --git a/examples/python/helloworld_direct.py b/examples/python/helloworld_direct.py
index 2ad78a7..d6374a2 100755
--- a/examples/python/helloworld_direct.py
+++ b/examples/python/helloworld_direct.py
@@ -18,6 +18,7 @@
# under the License.
#
+from __future__ import print_function
from proton import Message
from proton.handlers import MessagingHandler
from proton.reactor import Container
@@ -36,7 +37,7 @@ class HelloWorld(MessagingHandler):
event.sender.close()
def on_message(self, event):
- print event.message.body
+ print(event.message.body)
def on_accepted(self, event):
event.connection.close()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/helloworld_direct_tornado.py
----------------------------------------------------------------------
diff --git a/examples/python/helloworld_direct_tornado.py b/examples/python/helloworld_direct_tornado.py
index 2466f80..9ef2ed7 100755
--- a/examples/python/helloworld_direct_tornado.py
+++ b/examples/python/helloworld_direct_tornado.py
@@ -18,6 +18,7 @@
# under the License.
#
+from __future__ import print_function
from proton import Message
from proton.handlers import MessagingHandler
from proton_tornado import Container
@@ -36,7 +37,7 @@ class HelloWorld(MessagingHandler):
event.sender.close()
def on_message(self, event):
- print event.message.body
+ print(event.message.body)
def on_accepted(self, event):
event.connection.close()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/helloworld_tornado.py
----------------------------------------------------------------------
diff --git a/examples/python/helloworld_tornado.py b/examples/python/helloworld_tornado.py
index d4b32cf..3cb2ad1 100755
--- a/examples/python/helloworld_tornado.py
+++ b/examples/python/helloworld_tornado.py
@@ -18,6 +18,7 @@
# under the License.
#
+from __future__ import print_function
from proton import Message
from proton.handlers import MessagingHandler
from proton_tornado import Container
@@ -38,7 +39,7 @@ class HelloWorld(MessagingHandler):
event.sender.close()
def on_message(self, event):
- print event.message.body
+ print(event.message.body)
event.connection.close()
Container(HelloWorld("localhost:5672", "examples")).run()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/messenger/async.py
----------------------------------------------------------------------
diff --git a/examples/python/messenger/async.py b/examples/python/messenger/async.py
index 14fc4c9..b3f5c45 100755
--- a/examples/python/messenger/async.py
+++ b/examples/python/messenger/async.py
@@ -17,6 +17,7 @@
# specific language governing permissions and limitations
# under the License.
#
+from __future__ import print_function
import sys
from proton import *
@@ -72,7 +73,7 @@ class CallbackAdapter:
self.messenger.accept(t)
except:
ex = sys.exc_info()[1]
- print "Exception:", ex
+ print("Exception:", ex)
self.messenger.reject(t)
def send(self, message, on_status=None):
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/messenger/client.py
----------------------------------------------------------------------
diff --git a/examples/python/messenger/client.py b/examples/python/messenger/client.py
index 3146e45..62fc16e 100755
--- a/examples/python/messenger/client.py
+++ b/examples/python/messenger/client.py
@@ -17,6 +17,7 @@
# specific language governing permissions and limitations
# under the License.
#
+from __future__ import print_function
import sys, optparse
from proton import *
@@ -48,8 +49,8 @@ if opts.reply_to[:2] == "~/":
mng.recv(1)
try:
mng.get(msg)
- print msg.address, msg.subject
- except Exception, e:
- print e
+ print(msg.address, msg.subject)
+ except Exception as e:
+ print(e)
mng.stop()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/messenger/recv.py
----------------------------------------------------------------------
diff --git a/examples/python/messenger/recv.py b/examples/python/messenger/recv.py
index e19ddad..5771bd7 100755
--- a/examples/python/messenger/recv.py
+++ b/examples/python/messenger/recv.py
@@ -17,6 +17,7 @@
# specific language governing permissions and limitations
# under the License.
#
+from __future__ import print_function
import sys, optparse
from proton import *
@@ -46,9 +47,9 @@ while True:
while mng.incoming:
try:
mng.get(msg)
- except Exception, e:
- print e
+ except Exception as e:
+ print(e)
else:
- print msg.address, msg.subject or "(no subject)", msg.properties, msg.body
+ print(msg.address, msg.subject or "(no subject)", msg.properties, msg.body)
mng.stop()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/messenger/recv_async.py
----------------------------------------------------------------------
diff --git a/examples/python/messenger/recv_async.py b/examples/python/messenger/recv_async.py
index ba4f063..b38c31a 100755
--- a/examples/python/messenger/recv_async.py
+++ b/examples/python/messenger/recv_async.py
@@ -17,6 +17,7 @@
# specific language governing permissions and limitations
# under the License.
#
+from __future__ import print_function
import sys, optparse
from async import *
@@ -31,25 +32,25 @@ if not args:
class App(CallbackAdapter):
def on_start(self):
- print "Started"
+ print("Started")
for a in args:
- print "Subscribing to:", a
+ print("Subscribing to:", a)
self.messenger.subscribe(a)
self.messenger.recv()
def on_recv(self, msg):
- print "Received:", msg
+ print("Received:", msg)
if msg.body == "die":
self.stop()
if msg.reply_to:
self.message.clear()
self.message.address = msg.reply_to
self.message.body = "Reply for: %s" % msg.body
- print "Replied:", self.message
+ print("Replied:", self.message)
self.send(self.message)
def on_stop(self):
- print "Stopped"
+ print("Stopped")
a = App(Messenger())
a.run()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/messenger/send.py
----------------------------------------------------------------------
diff --git a/examples/python/messenger/send.py b/examples/python/messenger/send.py
index 139f6e8..f40e7b1 100755
--- a/examples/python/messenger/send.py
+++ b/examples/python/messenger/send.py
@@ -17,6 +17,7 @@
# specific language governing permissions and limitations
# under the License.
#
+from __future__ import print_function
import sys, optparse
from proton import *
@@ -39,6 +40,6 @@ for m in args:
mng.put(msg)
mng.send()
-print "sent:", ", ".join(args)
+print("sent:", ", ".join(args))
mng.stop()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/messenger/send_async.py
----------------------------------------------------------------------
diff --git a/examples/python/messenger/send_async.py b/examples/python/messenger/send_async.py
index 304aceb..50f7a68 100755
--- a/examples/python/messenger/send_async.py
+++ b/examples/python/messenger/send_async.py
@@ -17,6 +17,7 @@
# specific language governing permissions and limitations
# under the License.
#
+from __future__ import print_function
import sys, optparse
from async import *
@@ -33,7 +34,7 @@ if not args:
class App(CallbackAdapter):
def on_start(self):
- print "Started"
+ print("Started")
self.message.clear()
self.message.address = opts.address
self.message.reply_to = opts.reply_to
@@ -45,19 +46,19 @@ class App(CallbackAdapter):
self.messenger.recv()
def on_status(self, status):
- print "Status:", status
+ print("Status:", status)
if not opts.reply_to or opts.reply_to[0] != "~":
args.pop(0)
if not args: self.stop()
def on_recv(self, msg):
- print "Received:", msg
+ print("Received:", msg)
if opts.reply_to and opts.reply_to[0] == "~":
args.pop(0)
if not args: self.stop()
def on_stop(self):
- print "Stopped"
+ print("Stopped")
a = App(Messenger())
a.run()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/messenger/server.py
----------------------------------------------------------------------
diff --git a/examples/python/messenger/server.py b/examples/python/messenger/server.py
index 01196be..8c25879 100755
--- a/examples/python/messenger/server.py
+++ b/examples/python/messenger/server.py
@@ -17,6 +17,7 @@
# specific language governing permissions and limitations
# under the License.
#
+from __future__ import print_function
import sys, optparse
from proton import *
@@ -38,7 +39,7 @@ def dispatch(request, response):
if request.subject:
response.subject = "Re: %s" % request.subject
response.properties = request.properties
- print "Dispatched %s %s" % (request.subject, request.properties)
+ print("Dispatched %s %s" % (request.subject, request.properties))
msg = Message()
reply = Message()
@@ -50,7 +51,7 @@ while True:
if mng.incoming > 0:
mng.get(msg)
if msg.reply_to:
- print msg.reply_to
+ print(msg.reply_to)
reply.address = msg.reply_to
reply.correlation_id = msg.correlation_id
reply.body = msg.body
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/proton_server.py
----------------------------------------------------------------------
diff --git a/examples/python/proton_server.py b/examples/python/proton_server.py
index b92261c..c2520c1 100755
--- a/examples/python/proton_server.py
+++ b/examples/python/proton_server.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -38,7 +39,7 @@ class Server(MessagingHandler):
self.relay = self.container.create_sender(self.conn, None)
def on_connection_close(self, endpoint, error):
- if error: print "Closed due to %s" % error
+ if error: print("Closed due to %s" % error)
self.conn.close()
def run(self):
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/queue_browser.py
----------------------------------------------------------------------
diff --git a/examples/python/queue_browser.py b/examples/python/queue_browser.py
index ad4d393..34d2377 100755
--- a/examples/python/queue_browser.py
+++ b/examples/python/queue_browser.py
@@ -18,6 +18,7 @@
# under the License.
#
+from __future__ import print_function
from proton.reactor import Container, Copy
from proton.handlers import MessagingHandler
@@ -30,7 +31,7 @@ class Recv(MessagingHandler):
event.container.create_receiver(conn, "examples", options=Copy())
def on_message(self, event):
- print event.message
+ print(event.message)
if event.receiver.queued == 0 and event.receiver.drained:
event.connection.close()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/reactor/cat.py
----------------------------------------------------------------------
diff --git a/examples/python/reactor/cat.py b/examples/python/reactor/cat.py
index 57f4515..82ebd27 100755
--- a/examples/python/reactor/cat.py
+++ b/examples/python/reactor/cat.py
@@ -18,6 +18,7 @@
# under the License.
#
+from __future__ import print_function
import sys, os
from proton.reactor import Reactor
@@ -42,7 +43,7 @@ class Echo:
# to be read, or the end of stream has been reached.
data = os.read(sel.fileno(), 1024)
if data:
- print data,
+ print(data, end=' ')
else:
sel.terminate()
event.reactor.update(sel)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/reactor/count-randomly.py
----------------------------------------------------------------------
diff --git a/examples/python/reactor/count-randomly.py b/examples/python/reactor/count-randomly.py
index d9a32c6..fb3709a 100755
--- a/examples/python/reactor/count-randomly.py
+++ b/examples/python/reactor/count-randomly.py
@@ -18,6 +18,7 @@
# under the License.
#
+from __future__ import print_function
import time, random
from proton.reactor import Reactor
@@ -34,7 +35,7 @@ class Counter:
def on_timer_task(self, event):
self.count += 1
- print self.count
+ print(self.count)
if not self.done():
event.reactor.schedule(0.25, self)
@@ -46,7 +47,7 @@ class Program:
def on_reactor_init(self, event):
self.start = time.time()
- print "Hello, World!"
+ print("Hello, World!")
# Save the counter instance in an attribute so we can refer to
# it later.
@@ -60,12 +61,12 @@ class Program:
def on_timer_task(self, event):
# keep on shouting until we are done counting
- print "Yay, %s!" % random.randint(10, 100)
+ print("Yay, %s!" % random.randint(10, 100))
if not self.counter.done():
event.reactor.schedule(0.5, self)
def on_reactor_final(self, event):
- print "Goodbye, World! (after %s long seconds)" % (time.time() - self.start)
+ print("Goodbye, World! (after %s long seconds)" % (time.time() - self.start))
# In hello-world.py we said the reactor exits when there are no more
# events to process. While this is true, it's not actually complete.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/reactor/counter.py
----------------------------------------------------------------------
diff --git a/examples/python/reactor/counter.py b/examples/python/reactor/counter.py
index 1ef45f0..7c8167a 100755
--- a/examples/python/reactor/counter.py
+++ b/examples/python/reactor/counter.py
@@ -18,6 +18,7 @@
# under the License.
#
+from __future__ import print_function
import time
from proton.reactor import Reactor
@@ -29,7 +30,7 @@ class Counter:
def on_timer_task(self, event):
self.count += 1
- print self.count
+ print(self.count)
if self.count < self.limit:
# A recurring task can be acomplished by just scheduling
# another event.
@@ -39,7 +40,7 @@ class Program:
def on_reactor_init(self, event):
self.start = time.time()
- print "Hello, World!"
+ print("Hello, World!")
# Note that unlike the previous scheduling example, we pass in
# a separate object for the handler. This means that the timer
@@ -48,7 +49,7 @@ class Program:
event.reactor.schedule(0.25, Counter(10))
def on_reactor_final(self, event):
- print "Goodbye, World! (after %s long seconds)" % (time.time() - self.start)
+ print("Goodbye, World! (after %s long seconds)" % (time.time() - self.start))
# In hello-world.py we said the reactor exits when there are no more
# events to process. While this is true, it's not actually complete.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/reactor/delegates.py
----------------------------------------------------------------------
diff --git a/examples/python/reactor/delegates.py b/examples/python/reactor/delegates.py
index 813ceba..1a8e1e9 100755
--- a/examples/python/reactor/delegates.py
+++ b/examples/python/reactor/delegates.py
@@ -18,6 +18,7 @@
# under the License.
#
+from __future__ import print_function
import time
from proton.reactor import Reactor
@@ -28,12 +29,12 @@ from proton.reactor import Reactor
class Hello:
def on_reactor_init(self, event):
- print "Hello, World!"
+ print("Hello, World!")
class Goodbye:
def on_reactor_final(self, event):
- print "Goodbye, World!"
+ print("Goodbye, World!")
class Program:
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/reactor/echo.py
----------------------------------------------------------------------
diff --git a/examples/python/reactor/echo.py b/examples/python/reactor/echo.py
index 4675f5d..17529d9 100755
--- a/examples/python/reactor/echo.py
+++ b/examples/python/reactor/echo.py
@@ -18,6 +18,7 @@
# under the License.
#
+from __future__ import print_function
import sys, os
from proton.reactor import Reactor
@@ -42,7 +43,7 @@ class Echo:
# to be read, or the end of stream has been reached.
data = os.read(sel.fileno(), 1024)
if data:
- print data,
+ print(data, end=' ')
else:
sel.terminate()
event.reactor.update(sel)
@@ -54,7 +55,7 @@ class Program:
# selectable stays alive until it reads the end of stream
# marker. This will keep the whole reactor running until we
# type Control-D.
- print "Type whatever you want and then use Control-D to exit:"
+ print("Type whatever you want and then use Control-D to exit:")
event.reactor.selectable(Echo(sys.stdin))
r = Reactor(Program())
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/reactor/global-logger.py
----------------------------------------------------------------------
diff --git a/examples/python/reactor/global-logger.py b/examples/python/reactor/global-logger.py
index bc3bc56..3cbe11c 100755
--- a/examples/python/reactor/global-logger.py
+++ b/examples/python/reactor/global-logger.py
@@ -18,6 +18,7 @@
# under the License.
#
+from __future__ import print_function
import time
from proton.reactor import Reactor
@@ -30,21 +31,21 @@ from proton.reactor import Reactor
class Logger:
def on_unhandled(self, name, event):
- print "LOG:", name, event
+ print("LOG:", name, event)
class Task:
def on_timer_task(self, event):
- print "Mission accomplished!"
+ print("Mission accomplished!")
class Program:
def on_reactor_init(self, event):
- print "Hello, World!"
+ print("Hello, World!")
event.reactor.schedule(0, Task())
def on_reactor_final(self, event):
- print "Goodbye, World!"
+ print("Goodbye, World!")
r = Reactor(Program())
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/reactor/goodbye-world.py
----------------------------------------------------------------------
diff --git a/examples/python/reactor/goodbye-world.py b/examples/python/reactor/goodbye-world.py
index 44bcf7c..f251c8a 100755
--- a/examples/python/reactor/goodbye-world.py
+++ b/examples/python/reactor/goodbye-world.py
@@ -18,6 +18,7 @@
# under the License.
#
+from __future__ import print_function
from proton.reactor import Reactor
# So far the reactive hello-world doesn't look too different from a
@@ -30,7 +31,7 @@ class Program:
# As before we handle the reactor init event.
def on_reactor_init(self, event):
- print "Hello, World!"
+ print("Hello, World!")
# In addition to an initial event, the reactor also produces an
# event when it is about to exit. This may not behave much
@@ -40,7 +41,7 @@ class Program:
# regardless of what other paths the main logic of our program
# might take.
def on_reactor_final(self, event):
- print "Goodbye, World!"
+ print("Goodbye, World!")
r = Reactor(Program())
r.run()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/reactor/handlers.py
----------------------------------------------------------------------
diff --git a/examples/python/reactor/handlers.py b/examples/python/reactor/handlers.py
index ed3a94d..ee8d807 100755
--- a/examples/python/reactor/handlers.py
+++ b/examples/python/reactor/handlers.py
@@ -18,6 +18,7 @@
# under the License.
#
+from __future__ import print_function
import time
from proton.reactor import Reactor
@@ -25,12 +26,12 @@ from proton.reactor import Reactor
class World:
def on_reactor_init(self, event):
- print "World!"
+ print("World!")
class Goodbye:
def on_reactor_final(self, event):
- print "Goodbye, World!"
+ print("Goodbye, World!")
class Hello:
@@ -42,7 +43,7 @@ class Hello:
# The parent handler always receives the event first.
def on_reactor_init(self, event):
- print "Hello",
+ print("Hello", end=' ')
r = Reactor(Hello())
r.run()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/reactor/hello-world.py
----------------------------------------------------------------------
diff --git a/examples/python/reactor/hello-world.py b/examples/python/reactor/hello-world.py
index c685c73..f1708db 100755
--- a/examples/python/reactor/hello-world.py
+++ b/examples/python/reactor/hello-world.py
@@ -18,6 +18,7 @@
# under the License.
#
+from __future__ import print_function
from proton.reactor import Reactor
# The proton reactor provides a general purpose event processing
@@ -31,7 +32,7 @@ class Program:
# The reactor init event is produced by the reactor itself when it
# starts.
def on_reactor_init(self, event):
- print "Hello, World!"
+ print("Hello, World!")
# When you construct a reactor, you give it a handler.
r = Reactor(Program())
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/reactor/reactor-logger.py
----------------------------------------------------------------------
diff --git a/examples/python/reactor/reactor-logger.py b/examples/python/reactor/reactor-logger.py
index c07e9b9..2d3f9de 100755
--- a/examples/python/reactor/reactor-logger.py
+++ b/examples/python/reactor/reactor-logger.py
@@ -18,21 +18,22 @@
# under the License.
#
+from __future__ import print_function
import time
from proton.reactor import Reactor
class Logger:
def on_unhandled(self, name, event):
- print "LOG:", name, event
+ print("LOG:", name, event)
class Program:
def on_reactor_init(self, event):
- print "Hello, World!"
+ print("Hello, World!")
def on_reactor_final(self, event):
- print "Goodbye, World!"
+ print("Goodbye, World!")
# You can pass multiple handlers to a reactor when you construct it.
# Each of these handlers will see every event the reactor sees. By
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/reactor/recv.py
----------------------------------------------------------------------
diff --git a/examples/python/reactor/recv.py b/examples/python/reactor/recv.py
index aa56472..c6f07f1 100755
--- a/examples/python/reactor/recv.py
+++ b/examples/python/reactor/recv.py
@@ -18,6 +18,7 @@
# under the License.
#
+from __future__ import print_function
from proton import Message
from proton.reactor import Reactor
from proton.handlers import CHandshaker, CFlowController
@@ -41,7 +42,7 @@ class Program:
# compliment the similar thing on send
rcv = event.receiver
if rcv and self.message.recv(rcv):
- print self.message
+ print(self.message)
event.delivery.settle()
r = Reactor(Program())
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/reactor/scheduling.py
----------------------------------------------------------------------
diff --git a/examples/python/reactor/scheduling.py b/examples/python/reactor/scheduling.py
index f822f68..8956821 100755
--- a/examples/python/reactor/scheduling.py
+++ b/examples/python/reactor/scheduling.py
@@ -18,6 +18,7 @@
# under the License.
#
+from __future__ import print_function
import time
from proton.reactor import Reactor
@@ -25,7 +26,7 @@ class Program:
def on_reactor_init(self, event):
self.start = time.time()
- print "Hello, World!"
+ print("Hello, World!")
# We can schedule a task event for some point in the future.
# This will cause the reactor to stick around until it has a
@@ -42,10 +43,10 @@ class Program:
def on_timer_task(self, event):
task = event.context # xxx: don't have a task property on event yet
- print task.something_to_say, "my task is complete!"
+ print(task.something_to_say, "my task is complete!")
def on_reactor_final(self, event):
- print "Goodbye, World! (after %s long seconds)" % (time.time() - self.start)
+ print("Goodbye, World! (after %s long seconds)" % (time.time() - self.start))
r = Reactor(Program())
r.run()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/reactor/tornado-hello-world.py
----------------------------------------------------------------------
diff --git a/examples/python/reactor/tornado-hello-world.py b/examples/python/reactor/tornado-hello-world.py
index fa8ca83..d06cd1b 100755
--- a/examples/python/reactor/tornado-hello-world.py
+++ b/examples/python/reactor/tornado-hello-world.py
@@ -18,6 +18,7 @@
# under the License.
#
+from __future__ import print_function
import tornado.ioloop
from tornado_app import TornadoApp
@@ -32,7 +33,7 @@ class Program:
# The reactor init event is produced by the reactor itself when it
# starts.
def on_reactor_init(self, event):
- print "Hello, World!"
+ print("Hello, World!")
# The TornadoApp integrates a Reactor into tornado's ioloop.
TornadoApp(Program())
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/reactor/unhandled.py
----------------------------------------------------------------------
diff --git a/examples/python/reactor/unhandled.py b/examples/python/reactor/unhandled.py
index 3734a71..9ab2212 100755
--- a/examples/python/reactor/unhandled.py
+++ b/examples/python/reactor/unhandled.py
@@ -18,6 +18,7 @@
# under the License.
#
+from __future__ import print_function
import time
from proton.reactor import Reactor
@@ -28,7 +29,7 @@ class Program:
# if it exists. This can be useful not only for debugging, but for
# logging and for delegating/inheritance.
def on_unhandled(self, name, event):
- print name, event
+ print(name, event)
r = Reactor(Program())
r.run()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/recurring_timer.py
----------------------------------------------------------------------
diff --git a/examples/python/recurring_timer.py b/examples/python/recurring_timer.py
index a39791d..b59dbe1 100755
--- a/examples/python/recurring_timer.py
+++ b/examples/python/recurring_timer.py
@@ -18,6 +18,7 @@
# under the License.
#
+from __future__ import print_function
from proton.reactor import Container, Handler
class Recurring(Handler):
@@ -29,7 +30,7 @@ class Recurring(Handler):
self.container.schedule(self.period, self)
def on_timer_task(self, event):
- print "Tick..."
+ print("Tick...")
self.container.schedule(self.period, self)
try:
@@ -37,6 +38,6 @@ try:
container.run()
except KeyboardInterrupt:
container.stop()
- print
+ print()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/recurring_timer_tornado.py
----------------------------------------------------------------------
diff --git a/examples/python/recurring_timer_tornado.py b/examples/python/recurring_timer_tornado.py
index 1f1c0e7..07ebd26 100755
--- a/examples/python/recurring_timer_tornado.py
+++ b/examples/python/recurring_timer_tornado.py
@@ -18,6 +18,7 @@
# under the License.
#
+from __future__ import print_function
import time
from proton.reactor import Handler
from proton_tornado import TornadoLoop
@@ -31,7 +32,7 @@ class Recurring(Handler):
self.container.schedule(time.time() + self.period, subject=self)
def on_timer(self, event):
- print "Tick..."
+ print("Tick...")
self.container.schedule(time.time() + self.period, subject=self)
try:
@@ -39,6 +40,6 @@ try:
container.run()
except KeyboardInterrupt:
container.stop()
- print
+ print()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/selected_recv.py
----------------------------------------------------------------------
diff --git a/examples/python/selected_recv.py b/examples/python/selected_recv.py
index 351d4ef..2ea704b 100755
--- a/examples/python/selected_recv.py
+++ b/examples/python/selected_recv.py
@@ -18,6 +18,7 @@
# under the License.
#
+from __future__ import print_function
from proton.reactor import Container, Selector
from proton.handlers import MessagingHandler
@@ -30,7 +31,7 @@ class Recv(MessagingHandler):
event.container.create_receiver(conn, "examples", options=Selector(u"colour = 'green'"))
def on_message(self, event):
- print event.message.body
+ print(event.message.body)
try:
Container(Recv()).run()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/server.py
----------------------------------------------------------------------
diff --git a/examples/python/server.py b/examples/python/server.py
index 62aa162..3b0a085 100755
--- a/examples/python/server.py
+++ b/examples/python/server.py
@@ -18,6 +18,7 @@
# under the License.
#
+from __future__ import print_function
from proton import Message
from proton.handlers import MessagingHandler
from proton.reactor import Container
@@ -30,7 +31,7 @@ class Server(MessagingHandler):
self.senders = {}
def on_start(self, event):
- print "Listening on", self.url
+ print("Listening on", self.url)
self.container = event.container
self.conn = event.container.connect(self.url)
self.receiver = event.container.create_receiver(self.conn, self.address)
@@ -41,7 +42,7 @@ class Server(MessagingHandler):
self.relay = self.container.create_sender(self.conn, None)
def on_message(self, event):
- print "Received", event.message
+ print("Received", event.message)
sender = self.relay or self.senders.get(event.message.reply_to)
if not sender:
sender = self.container.create_sender(self.conn, event.message.reply_to)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/server_direct.py
----------------------------------------------------------------------
diff --git a/examples/python/server_direct.py b/examples/python/server_direct.py
index 18a20f3..a9910f1 100755
--- a/examples/python/server_direct.py
+++ b/examples/python/server_direct.py
@@ -18,6 +18,7 @@
# under the License.
#
+from __future__ import print_function
from proton import generate_uuid, Message
from proton.handlers import MessagingHandler
from proton.reactor import Container
@@ -29,7 +30,7 @@ class Server(MessagingHandler):
self.senders = {}
def on_start(self, event):
- print "Listening on", self.url
+ print("Listening on", self.url)
self.container = event.container
self.acceptor = event.container.listen(self.url)
@@ -47,10 +48,10 @@ class Server(MessagingHandler):
event.link.target.address = event.link.remote_target.address
def on_message(self, event):
- print "Received", event.message
+ print("Received", event.message)
sender = self.senders.get(event.message.reply_to)
if not sender:
- print "No link for reply"
+ print("No link for reply")
return
sender.send(Message(address=event.message.reply_to, body=event.message.body.upper(),
correlation_id=event.message.correlation_id))
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/server_tx.py
----------------------------------------------------------------------
diff --git a/examples/python/server_tx.py b/examples/python/server_tx.py
index 96b83cb..51e734c 100755
--- a/examples/python/server_tx.py
+++ b/examples/python/server_tx.py
@@ -18,6 +18,7 @@
# under the License.
#
+from __future__ import print_function
from proton import Message
from proton.reactor import Container
from proton.handlers import MessagingHandler, TransactionHandler
@@ -35,10 +36,10 @@ class TxRequest(TransactionHandler):
event.transaction.commit()
def on_transaction_committed(self, event):
- print "Request processed successfully"
+ print("Request processed successfully")
def on_transaction_aborted(self, event):
- print "Request processing aborted"
+ print("Request processing aborted")
class TxServer(MessagingHandler):
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/simple_recv.py
----------------------------------------------------------------------
diff --git a/examples/python/simple_recv.py b/examples/python/simple_recv.py
index abe30cd..5322500 100755
--- a/examples/python/simple_recv.py
+++ b/examples/python/simple_recv.py
@@ -18,6 +18,7 @@
# under the License.
#
+from __future__ import print_function
import optparse
from proton.handlers import MessagingHandler
from proton.reactor import Container
@@ -37,7 +38,7 @@ class Recv(MessagingHandler):
# ignore duplicate message
return
if self.expected == 0 or self.received < self.expected:
- print event.message.body
+ print(event.message.body)
self.received += 1
if self.received == self.expected:
event.receiver.close()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/simple_send.py
----------------------------------------------------------------------
diff --git a/examples/python/simple_send.py b/examples/python/simple_send.py
index 4158272..75ab550 100755
--- a/examples/python/simple_send.py
+++ b/examples/python/simple_send.py
@@ -18,6 +18,7 @@
# under the License.
#
+from __future__ import print_function
import optparse
from proton import Message
from proton.handlers import MessagingHandler
@@ -43,7 +44,7 @@ class Send(MessagingHandler):
def on_accepted(self, event):
self.confirmed += 1
if self.confirmed == self.total:
- print "all messages confirmed"
+ print("all messages confirmed")
event.connection.close()
def on_disconnected(self, event):
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/sync_client.py
----------------------------------------------------------------------
diff --git a/examples/python/sync_client.py b/examples/python/sync_client.py
index 82cd85f..95a5650 100755
--- a/examples/python/sync_client.py
+++ b/examples/python/sync_client.py
@@ -23,6 +23,7 @@ Demonstrates the client side of the synchronous request-response pattern
(also known as RPC or Remote Procecure Call) using proton.
"""
+from __future__ import print_function
import optparse
from proton import Message, Url, ConnectionException, Timeout
@@ -48,7 +49,7 @@ try:
"And the mome raths outgrabe."]
for request in REQUESTS:
response = client.call(Message(body=request))
- print "%s => %s" % (request, response.body)
+ print("%s => %s" % (request, response.body))
finally:
client.connection.close()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/tx_recv.py
----------------------------------------------------------------------
diff --git a/examples/python/tx_recv.py b/examples/python/tx_recv.py
index 641f0a2..4baddcf 100755
--- a/examples/python/tx_recv.py
+++ b/examples/python/tx_recv.py
@@ -18,6 +18,7 @@
# under the License.
#
+from __future__ import print_function
import optparse
from proton import Url
from proton.reactor import Container
@@ -40,7 +41,7 @@ class TxRecv(MessagingHandler, TransactionHandler):
self.transaction = None
def on_message(self, event):
- print event.message.body
+ print(event.message.body)
self.transaction.accept(event.delivery)
self.current_batch += 1
if self.current_batch == self.batch_size:
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/tx_recv_interactive.py
----------------------------------------------------------------------
diff --git a/examples/python/tx_recv_interactive.py b/examples/python/tx_recv_interactive.py
index d08ff2b..2c1d9a7 100755
--- a/examples/python/tx_recv_interactive.py
+++ b/examples/python/tx_recv_interactive.py
@@ -18,6 +18,7 @@
# under the License.
#
+from __future__ import print_function
import sys
import threading
from proton.reactor import ApplicationEvent, Container
@@ -35,19 +36,19 @@ class TxRecv(MessagingHandler, TransactionHandler):
self.transaction = None
def on_message(self, event):
- print event.message.body
+ print(event.message.body)
self.transaction.accept(event.delivery)
def on_transaction_declared(self, event):
self.transaction = event.transaction
- print "transaction declared"
+ print("transaction declared")
def on_transaction_committed(self, event):
- print "transaction committed"
+ print("transaction committed")
self.container.declare_transaction(self.conn, handler=self)
def on_transaction_aborted(self, event):
- print "transaction aborted"
+ print("transaction aborted")
self.container.declare_transaction(self.conn, handler=self)
def on_commit(self, event):
@@ -71,7 +72,7 @@ try:
thread.daemon=True
thread.start()
- print "Enter 'fetch', 'commit' or 'abort'"
+ print("Enter 'fetch', 'commit' or 'abort'")
while True:
line = sys.stdin.readline()
if line:
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aae1d20a/examples/python/tx_send.py
----------------------------------------------------------------------
diff --git a/examples/python/tx_send.py b/examples/python/tx_send.py
index 0f1da5a..5e30174 100755
--- a/examples/python/tx_send.py
+++ b/examples/python/tx_send.py
@@ -18,6 +18,7 @@
# under the License.
#
+from __future__ import print_function
import optparse
from proton import Message, Url
from proton.reactor import Container
@@ -64,7 +65,7 @@ class TxSend(MessagingHandler, TransactionHandler):
def on_transaction_committed(self, event):
self.committed += self.current_batch
if self.committed == self.total:
- print "all messages committed"
+ print("all messages committed")
event.connection.close()
else:
self.current_batch = 0
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org