diff options
author | Nobuaki Sukegawa <nsuke@apache.org> | 2015-11-06 21:24:16 +0900 |
---|---|---|
committer | Nobuaki Sukegawa <nsuke@apache.org> | 2015-11-06 21:24:16 +0900 |
commit | 760511f59b349c59982a64e249e6cf24c2b2f8f6 (patch) | |
tree | 793e2daab17a717fb2407a60627f65073daa82e5 /tutorial/py.twisted | |
parent | 49f4dc0cd8c87213a0f80ae1daba2d094a358ea7 (diff) | |
download | thrift-760511f59b349c59982a64e249e6cf24c2b2f8f6.tar.gz |
THRIFT-1857 Python 3 Support
Client: Python
Patch: Thomas Bartelmess, Eevee (Alex Munroe), helgridly, Christian Verkerk, Jeroen Vlek, Nobuaki Sukegawa
This closes #213 and closes #680
Diffstat (limited to 'tutorial/py.twisted')
-rwxr-xr-x | tutorial/py.twisted/PythonClient.py | 16 | ||||
-rwxr-xr-x | tutorial/py.twisted/PythonServer.py | 14 | ||||
-rwxr-xr-x | tutorial/py.twisted/PythonServer.tac | 2 |
3 files changed, 16 insertions, 16 deletions
diff --git a/tutorial/py.twisted/PythonClient.py b/tutorial/py.twisted/PythonClient.py index 9e086f042..e80c0fc09 100755 --- a/tutorial/py.twisted/PythonClient.py +++ b/tutorial/py.twisted/PythonClient.py @@ -21,7 +21,7 @@ import sys, glob sys.path.append('gen-py.twisted') -sys.path.insert(0, glob.glob('../../lib/py/build/lib.*')[0]) +sys.path.insert(0, glob.glob('../../lib/py/build/lib*')[0]) from tutorial import Calculator from tutorial.ttypes import * @@ -37,10 +37,10 @@ from thrift.protocol import TBinaryProtocol @inlineCallbacks def main(client): yield client.ping() - print 'ping()' + print('ping()') sum = yield client.add(1,1) - print '1+1=%d' % (sum) + print(('1+1=%d' % (sum))) work = Work() @@ -50,19 +50,19 @@ def main(client): try: quotient = yield client.calculate(1, work) - print 'Whoa? You know how to divide by zero?' - except InvalidOperation, io: - print 'InvalidOperation: %r' % io + print('Whoa? You know how to divide by zero?') + except InvalidOperation as e: + print(('InvalidOperation: %r' % e)) work.op = Operation.SUBTRACT work.num1 = 15 work.num2 = 10 diff = yield client.calculate(1, work) - print '15-10=%d' % (diff) + print(('15-10=%d' % (diff))) log = yield client.getStruct(1) - print 'Check log: %s' % (log.value) + print(('Check log: %s' % (log.value))) reactor.stop() if __name__ == '__main__': diff --git a/tutorial/py.twisted/PythonServer.py b/tutorial/py.twisted/PythonServer.py index 227f6d4a2..c57832148 100755 --- a/tutorial/py.twisted/PythonServer.py +++ b/tutorial/py.twisted/PythonServer.py @@ -21,7 +21,7 @@ import sys, glob sys.path.append('gen-py.twisted') -sys.path.insert(0, glob.glob('../../lib/py/build/lib.*')[0]) +sys.path.insert(0, glob.glob('../../lib/py/build/lib*')[0]) from tutorial import Calculator from tutorial.ttypes import * @@ -36,19 +36,19 @@ from thrift.protocol import TBinaryProtocol from thrift.server import TServer class CalculatorHandler: - implements(Calculator.Iface) + implements(Calculator.Iface) def __init__(self): self.log = {} def ping(self): - print 'ping()' + print('ping()') def add(self, n1, n2): - print 'add(%d,%d)' % (n1, n2) + print('add(%d,%d)' % (n1, n2)) return n1+n2 def calculate(self, logid, work): - print 'calculate(%d, %r)' % (logid, work) + print('calculate(%d, %r)' % (logid, work)) if work.op == Operation.ADD: val = work.num1 + work.num2 @@ -77,11 +77,11 @@ class CalculatorHandler: return val def getStruct(self, key): - print 'getStruct(%d)' % (key) + print('getStruct(%d)' % (key)) return self.log[key] def zip(self): - print 'zip()' + print('zip()') if __name__ == '__main__': handler = CalculatorHandler() diff --git a/tutorial/py.twisted/PythonServer.tac b/tutorial/py.twisted/PythonServer.tac index 1d0b6c4b1..08493ff1f 100755 --- a/tutorial/py.twisted/PythonServer.tac +++ b/tutorial/py.twisted/PythonServer.tac @@ -24,7 +24,7 @@ from thrift.transport import TTwisted import sys, glob sys.path.append('gen-py.twisted') -sys.path.insert(0, glob.glob('../../lib/py/build/lib.*')[0]) +sys.path.insert(0, glob.glob('../../lib/py/build/lib*')[0]) from tutorial import Calculator from tutorial.ttypes import * from PythonServer import CalculatorHandler |