From 2e14e70f808759fd4e307f0fd36641edd48a3d26 Mon Sep 17 00:00:00 2001 From: WooParadog Date: Thu, 10 Jan 2019 17:23:35 +0800 Subject: [PATCH 1/6] Fix travis ci(again) --- .travis.yml | 33 +++++++++++++++++---------------- test_requirements_py27.txt | 2 +- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/.travis.yml b/.travis.yml index 759d7fb..016afe2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,27 +1,28 @@ language: python sudo: required +dist: xenial + +matrix: + include: + - python: 2.7 + env: TOXENV=py27 + - python: 3.4 + env: TOXENV=py34 + - python: 3.5 + env: TOXENV=py35 + - python: 3.6 + env: TOXENV=py36 + install: - pip install tox -env: - - TOXENV=py27 - - TOXENV=py34 - - TOXENV=py35 + script: - tox -cache: - directories: - - thrift-0.9.3 - before_install: - - pyenv global system 3.5 - - ls "thrift-0.9.3" | grep "bootstrap.sh" || wget https://github.com/apache/thrift/archive/0.9.3.tar.gz -O thrift.tar.gz - - ls "thrift-0.9.3" | grep "bootstrap.sh" || tar xf thrift.tar.gz - - cd thrift-0.9.3 - - ./bootstrap.sh - - ./configure --without-haskell --without-java --without-php --without-nodejs --without-cpp --without-lua --without-perl --without-ruby --without-erlang --without-rust --without-c_glib --without-go - - make - - sudo make install + - sudo apt-get update + - sudo apt-get install -y thrift-compiler + after_success: - pip install python-coveralls - coveralls diff --git a/test_requirements_py27.txt b/test_requirements_py27.txt index 4733a4a..c3eb3ea 100644 --- a/test_requirements_py27.txt +++ b/test_requirements_py27.txt @@ -1,4 +1,4 @@ pytest pytest-cov gevent==1.2.2 -thrift>=0.9.3 +thrift==0.9.3 From 061bcad311eb6d02e5d008b4f54d579e5c168b50 Mon Sep 17 00:00:00 2001 From: WooParadog Date: Thu, 10 Jan 2019 17:23:51 +0800 Subject: [PATCH 2/6] Drop 3.2/3.4 support --- setup.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 099e96f..9b9a1c5 100644 --- a/setup.py +++ b/setup.py @@ -18,9 +18,9 @@ 'Operating System :: POSIX', 'Programming Language :: Python', 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3.2', - 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', 'Topic :: Utilities', 'Topic :: Software Development :: Libraries :: Python Modules', ] @@ -30,8 +30,8 @@ # read dev requirements if PY_VERSION < (2, 7, 0): raise RuntimeError('Python < 2.7 is unsupported') -elif PY_VERSION >= (3, 0, 0) and PY_VERSION < (3, 2, 0): - raise RuntimeError('Python 3 < 3.2 is unsupported') +elif PY_VERSION >= (3, 0, 0) and PY_VERSION < (3, 4, 0): + raise RuntimeError('Python 3 < 3.4 is unsupported') if PY_VERSION[0] == 2: fname = os.path.join(os.path.dirname(__file__), 'requirements_py27.txt') From 445bf16fc4c90a7d0f055bcf03701e0125810404 Mon Sep 17 00:00:00 2001 From: WooParadog Date: Sat, 9 Feb 2019 17:27:34 +0800 Subject: [PATCH 3/6] Fix thriftpy test case --- tests/thriftpy_app.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/thriftpy_app.py b/tests/thriftpy_app.py index d7f15a9..48042c8 100644 --- a/tests/thriftpy_app.py +++ b/tests/thriftpy_app.py @@ -6,7 +6,6 @@ import thriftpy2 from thriftpy2.thrift import TProcessor -from . import AboutToShutDownException pingpong_thrift = thriftpy2.load( os.path.join( @@ -20,7 +19,7 @@ class PingpongServer(object): def ping(self): if os.environ.get('about_to_shutdown') == '1': - raise AboutToShutDownException + raise pingpong_thrift.AboutToShutDownException return "pong" From e9eec68a2ec1a261502f153c33d3be0a05d86626 Mon Sep 17 00:00:00 2001 From: WooParadog Date: Sat, 9 Feb 2019 19:41:04 +0800 Subject: [PATCH 4/6] Add futures==3.2.0 for python 2.7 --- test_requirements_py27.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/test_requirements_py27.txt b/test_requirements_py27.txt index c3eb3ea..444d175 100644 --- a/test_requirements_py27.txt +++ b/test_requirements_py27.txt @@ -2,3 +2,4 @@ pytest pytest-cov gevent==1.2.2 thrift==0.9.3 +futures==3.2.0 From 464ee790ed9287799a056ba89d3b93fdbe24dc74 Mon Sep 17 00:00:00 2001 From: WooParadog Date: Sat, 9 Feb 2019 17:24:07 +0800 Subject: [PATCH 5/6] Update pingpong_sdk --- .../pingpong_sdk/pingpong/PingService-remote | 125 +++--- tests/pingpong_sdk/pingpong/PingService.py | 407 +++++++++--------- tests/pingpong_sdk/pingpong/constants.py | 9 +- tests/pingpong_sdk/pingpong/ttypes.py | 145 +++---- 4 files changed, 354 insertions(+), 332 deletions(-) diff --git a/tests/pingpong_sdk/pingpong/PingService-remote b/tests/pingpong_sdk/pingpong/PingService-remote index f3b64fc..5deb11b 100755 --- a/tests/pingpong_sdk/pingpong/PingService-remote +++ b/tests/pingpong_sdk/pingpong/PingService-remote @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Autogenerated by Thrift Compiler (0.9.3) +# Autogenerated by Thrift Compiler (0.12.0) # # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING # @@ -9,86 +9,109 @@ import sys import pprint -from urlparse import urlparse -from thrift.transport import TTransport -from thrift.transport import TSocket -from thrift.transport import TSSLSocket -from thrift.transport import THttpClient -from thrift.protocol import TBinaryProtocol +if sys.version_info[0] > 2: + from urllib.parse import urlparse +else: + from urlparse import urlparse +from thrift.transport import TTransport, TSocket, TSSLSocket, THttpClient +from thrift.protocol.TBinaryProtocol import TBinaryProtocol from pingpong import PingService from pingpong.ttypes import * if len(sys.argv) <= 1 or sys.argv[1] == '--help': - print('') - print('Usage: ' + sys.argv[0] + ' [-h host[:port]] [-u url] [-f[ramed]] [-s[sl]] function [arg1 [arg2...]]') - print('') - print('Functions:') - print(' string ping()') - print('') - sys.exit(0) - -pp = pprint.PrettyPrinter(indent = 2) + print('') + print('Usage: ' + sys.argv[0] + ' [-h host[:port]] [-u url] [-f[ramed]] [-s[sl]] [-novalidate] [-ca_certs certs] [-keyfile keyfile] [-certfile certfile] function [arg1 [arg2...]]') + print('') + print('Functions:') + print(' string ping()') + print('') + sys.exit(0) + +pp = pprint.PrettyPrinter(indent=2) host = 'localhost' port = 9090 uri = '' framed = False ssl = False +validate = True +ca_certs = None +keyfile = None +certfile = None http = False argi = 1 if sys.argv[argi] == '-h': - parts = sys.argv[argi+1].split(':') - host = parts[0] - if len(parts) > 1: - port = int(parts[1]) - argi += 2 + parts = sys.argv[argi + 1].split(':') + host = parts[0] + if len(parts) > 1: + port = int(parts[1]) + argi += 2 if sys.argv[argi] == '-u': - url = urlparse(sys.argv[argi+1]) - parts = url[1].split(':') - host = parts[0] - if len(parts) > 1: - port = int(parts[1]) - else: - port = 80 - uri = url[2] - if url[4]: - uri += '?%s' % url[4] - http = True - argi += 2 + url = urlparse(sys.argv[argi + 1]) + parts = url[1].split(':') + host = parts[0] + if len(parts) > 1: + port = int(parts[1]) + else: + port = 80 + uri = url[2] + if url[4]: + uri += '?%s' % url[4] + http = True + argi += 2 if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed': - framed = True - argi += 1 + framed = True + argi += 1 if sys.argv[argi] == '-s' or sys.argv[argi] == '-ssl': - ssl = True - argi += 1 + ssl = True + argi += 1 + +if sys.argv[argi] == '-novalidate': + validate = False + argi += 1 + +if sys.argv[argi] == '-ca_certs': + ca_certs = sys.argv[argi+1] + argi += 2 + +if sys.argv[argi] == '-keyfile': + keyfile = sys.argv[argi+1] + argi += 2 + +if sys.argv[argi] == '-certfile': + certfile = sys.argv[argi+1] + argi += 2 cmd = sys.argv[argi] -args = sys.argv[argi+1:] +args = sys.argv[argi + 1:] if http: - transport = THttpClient.THttpClient(host, port, uri) + transport = THttpClient.THttpClient(host, port, uri) else: - socket = TSSLSocket.TSSLSocket(host, port, validate=False) if ssl else TSocket.TSocket(host, port) - if framed: - transport = TTransport.TFramedTransport(socket) - else: - transport = TTransport.TBufferedTransport(socket) -protocol = TBinaryProtocol.TBinaryProtocol(transport) + if ssl: + socket = TSSLSocket.TSSLSocket(host, port, validate=validate, ca_certs=ca_certs, keyfile=keyfile, certfile=certfile) + else: + socket = TSocket.TSocket(host, port) + if framed: + transport = TTransport.TFramedTransport(socket) + else: + transport = TTransport.TBufferedTransport(socket) +protocol = TBinaryProtocol(transport) client = PingService.Client(protocol) transport.open() if cmd == 'ping': - if len(args) != 0: - print('ping requires 0 args') - sys.exit(1) - pp.pprint(client.ping()) + if len(args) != 0: + print('ping requires 0 args') + sys.exit(1) + pp.pprint(client.ping()) else: - print('Unrecognized method %s' % cmd) - sys.exit(1) + print('Unrecognized method %s' % cmd) + sys.exit(1) transport.close() diff --git a/tests/pingpong_sdk/pingpong/PingService.py b/tests/pingpong_sdk/pingpong/PingService.py index 13f2df4..ac55f0d 100644 --- a/tests/pingpong_sdk/pingpong/PingService.py +++ b/tests/pingpong_sdk/pingpong/PingService.py @@ -1,230 +1,229 @@ # -# Autogenerated by Thrift Compiler (0.9.3) +# Autogenerated by Thrift Compiler (0.12.0) # # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING # # options string: py:new_style,utf8strings # -from thrift.Thrift import TType, TMessageType, TException, TApplicationException +from thrift.Thrift import TType, TMessageType, TFrozenDict, TException, TApplicationException +from thrift.protocol.TProtocol import TProtocolException +from thrift.TRecursive import fix_spec + +import sys import logging -from ttypes import * +from .ttypes import * from thrift.Thrift import TProcessor from thrift.transport import TTransport -from thrift.protocol import TBinaryProtocol, TProtocol -try: - from thrift.protocol import fastbinary -except: - fastbinary = None +all_structs = [] class Iface(object): - def ping(self): - pass + def ping(self): + pass class Client(Iface): - def __init__(self, iprot, oprot=None): - self._iprot = self._oprot = iprot - if oprot is not None: - self._oprot = oprot - self._seqid = 0 - - def ping(self): - self.send_ping() - return self.recv_ping() - - def send_ping(self): - self._oprot.writeMessageBegin('ping', TMessageType.CALL, self._seqid) - args = ping_args() - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_ping(self): - iprot = self._iprot - (fname, mtype, rseqid) = iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(iprot) - iprot.readMessageEnd() - raise x - result = ping_result() - result.read(iprot) - iprot.readMessageEnd() - if result.success is not None: - return result.success - if result.shutdown_exception is not None: - raise result.shutdown_exception - raise TApplicationException(TApplicationException.MISSING_RESULT, "ping failed: unknown result") + def __init__(self, iprot, oprot=None): + self._iprot = self._oprot = iprot + if oprot is not None: + self._oprot = oprot + self._seqid = 0 + + def ping(self): + self.send_ping() + return self.recv_ping() + + def send_ping(self): + self._oprot.writeMessageBegin('ping', TMessageType.CALL, self._seqid) + args = ping_args() + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_ping(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = ping_result() + result.read(iprot) + iprot.readMessageEnd() + if result.success is not None: + return result.success + if result.shutdown_exception is not None: + raise result.shutdown_exception + raise TApplicationException(TApplicationException.MISSING_RESULT, "ping failed: unknown result") class Processor(Iface, TProcessor): - def __init__(self, handler): - self._handler = handler - self._processMap = {} - self._processMap["ping"] = Processor.process_ping - - def process(self, iprot, oprot): - (name, type, seqid) = iprot.readMessageBegin() - if name not in self._processMap: - iprot.skip(TType.STRUCT) - iprot.readMessageEnd() - x = TApplicationException(TApplicationException.UNKNOWN_METHOD, 'Unknown function %s' % (name)) - oprot.writeMessageBegin(name, TMessageType.EXCEPTION, seqid) - x.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - return - else: - self._processMap[name](self, seqid, iprot, oprot) - return True - - def process_ping(self, seqid, iprot, oprot): - args = ping_args() - args.read(iprot) - iprot.readMessageEnd() - result = ping_result() - try: - result.success = self._handler.ping() - msg_type = TMessageType.REPLY - except (TTransport.TTransportException, KeyboardInterrupt, SystemExit): - raise - except AboutToShutDownException as shutdown_exception: - msg_type = TMessageType.REPLY - result.shutdown_exception = shutdown_exception - except Exception as ex: - msg_type = TMessageType.EXCEPTION - logging.exception(ex) - result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') - oprot.writeMessageBegin("ping", msg_type, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - + def __init__(self, handler): + self._handler = handler + self._processMap = {} + self._processMap["ping"] = Processor.process_ping + + def process(self, iprot, oprot): + (name, type, seqid) = iprot.readMessageBegin() + if name not in self._processMap: + iprot.skip(TType.STRUCT) + iprot.readMessageEnd() + x = TApplicationException(TApplicationException.UNKNOWN_METHOD, 'Unknown function %s' % (name)) + oprot.writeMessageBegin(name, TMessageType.EXCEPTION, seqid) + x.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + return + else: + self._processMap[name](self, seqid, iprot, oprot) + return True + + def process_ping(self, seqid, iprot, oprot): + args = ping_args() + args.read(iprot) + iprot.readMessageEnd() + result = ping_result() + try: + result.success = self._handler.ping() + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except AboutToShutDownException as shutdown_exception: + msg_type = TMessageType.REPLY + result.shutdown_exception = shutdown_exception + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("ping", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() # HELPER FUNCTIONS AND STRUCTURES + class ping_args(object): - thrift_spec = ( - ) - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('ping_args') - oprot.writeFieldStop() - oprot.writeStructEnd() - - def validate(self): - return - - - def __hash__(self): - value = 17 - return value - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('ping_args') + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(ping_args) +ping_args.thrift_spec = ( +) + class ping_result(object): - """ - Attributes: - - success - - shutdown_exception - """ - - thrift_spec = ( - (0, TType.STRING, 'success', None, None, ), # 0 - (1, TType.STRUCT, 'shutdown_exception', (AboutToShutDownException, AboutToShutDownException.thrift_spec), None, ), # 1 - ) - - def __init__(self, success=None, shutdown_exception=None,): - self.success = success - self.shutdown_exception = shutdown_exception - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.STRING: - self.success = iprot.readString().decode('utf-8') - else: - iprot.skip(ftype) - elif fid == 1: - if ftype == TType.STRUCT: - self.shutdown_exception = AboutToShutDownException() - self.shutdown_exception.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('ping_result') - if self.success is not None: - oprot.writeFieldBegin('success', TType.STRING, 0) - oprot.writeString(self.success.encode('utf-8')) - oprot.writeFieldEnd() - if self.shutdown_exception is not None: - oprot.writeFieldBegin('shutdown_exception', TType.STRUCT, 1) - self.shutdown_exception.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def validate(self): - return - - - def __hash__(self): - value = 17 - value = (value * 31) ^ hash(self.success) - value = (value * 31) ^ hash(self.shutdown_exception) - return value - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) + """ + Attributes: + - success + - shutdown_exception + + """ + + + def __init__(self, success=None, shutdown_exception=None,): + self.success = success + self.shutdown_exception = shutdown_exception + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.STRING: + self.success = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.shutdown_exception = AboutToShutDownException() + self.shutdown_exception.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('ping_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.STRING, 0) + oprot.writeString(self.success.encode('utf-8') if sys.version_info[0] == 2 else self.success) + oprot.writeFieldEnd() + if self.shutdown_exception is not None: + oprot.writeFieldBegin('shutdown_exception', TType.STRUCT, 1) + self.shutdown_exception.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(ping_result) +ping_result.thrift_spec = ( + (0, TType.STRING, 'success', 'UTF8', None, ), # 0 + (1, TType.STRUCT, 'shutdown_exception', [AboutToShutDownException, None], None, ), # 1 +) +fix_spec(all_structs) +del all_structs + diff --git a/tests/pingpong_sdk/pingpong/constants.py b/tests/pingpong_sdk/pingpong/constants.py index e42c63b..d829e19 100644 --- a/tests/pingpong_sdk/pingpong/constants.py +++ b/tests/pingpong_sdk/pingpong/constants.py @@ -1,11 +1,14 @@ # -# Autogenerated by Thrift Compiler (0.9.3) +# Autogenerated by Thrift Compiler (0.12.0) # # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING # # options string: py:new_style,utf8strings # -from thrift.Thrift import TType, TMessageType, TException, TApplicationException -from ttypes import * +from thrift.Thrift import TType, TMessageType, TFrozenDict, TException, TApplicationException +from thrift.protocol.TProtocol import TProtocolException +from thrift.TRecursive import fix_spec +import sys +from .ttypes import * diff --git a/tests/pingpong_sdk/pingpong/ttypes.py b/tests/pingpong_sdk/pingpong/ttypes.py index 7411321..47121ab 100644 --- a/tests/pingpong_sdk/pingpong/ttypes.py +++ b/tests/pingpong_sdk/pingpong/ttypes.py @@ -1,86 +1,83 @@ # -# Autogenerated by Thrift Compiler (0.9.3) +# Autogenerated by Thrift Compiler (0.12.0) # # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING # # options string: py:new_style,utf8strings # -from thrift.Thrift import TType, TMessageType, TException, TApplicationException +from thrift.Thrift import TType, TMessageType, TFrozenDict, TException, TApplicationException +from thrift.protocol.TProtocol import TProtocolException +from thrift.TRecursive import fix_spec -from thrift.transport import TTransport -from thrift.protocol import TBinaryProtocol, TProtocol -try: - from thrift.protocol import fastbinary -except: - fastbinary = None +import sys +from thrift.transport import TTransport +all_structs = [] class AboutToShutDownException(TException): - """ - Attributes: - - why - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'why', None, None, ), # 1 - ) - - def __init__(self, why=None,): - self.why = why - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.why = iprot.readString().decode('utf-8') - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('AboutToShutDownException') - if self.why is not None: - oprot.writeFieldBegin('why', TType.STRING, 1) - oprot.writeString(self.why.encode('utf-8')) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def validate(self): - return - - - def __str__(self): - return repr(self) - - def __hash__(self): - value = 17 - value = (value * 31) ^ hash(self.why) - return value - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) + """ + Attributes: + - why + + """ + + + def __init__(self, why=None,): + self.why = why + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.why = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('AboutToShutDownException') + if self.why is not None: + oprot.writeFieldBegin('why', TType.STRING, 1) + oprot.writeString(self.why.encode('utf-8') if sys.version_info[0] == 2 else self.why) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __str__(self): + return repr(self) + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(AboutToShutDownException) +AboutToShutDownException.thrift_spec = ( + None, # 0 + (1, TType.STRING, 'why', 'UTF8', None, ), # 1 +) +fix_spec(all_structs) +del all_structs From f751326d107b94012a070a99b6f043a5cb36f4bc Mon Sep 17 00:00:00 2001 From: Gwo Date: Sat, 16 Mar 2019 11:45:41 +0800 Subject: [PATCH 6/6] Add python 3.7 support --- .travis.yml | 2 ++ setup.py | 1 + tox.ini | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 016afe2..4d172eb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,8 @@ matrix: env: TOXENV=py35 - python: 3.6 env: TOXENV=py36 + - python: 3.7 + env: TOXENV=py37 install: - pip install tox diff --git a/setup.py b/setup.py index 9b9a1c5..f8462f8 100644 --- a/setup.py +++ b/setup.py @@ -21,6 +21,7 @@ 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', 'Topic :: Utilities', 'Topic :: Software Development :: Libraries :: Python Modules', ] diff --git a/tox.ini b/tox.ini index 7a15fdf..6be2849 100644 --- a/tox.ini +++ b/tox.ini @@ -7,5 +7,5 @@ deps = pytest pytest-cov py27: -r{toxinidir}/test_requirements_py27.txt - py{34,35,36}: -r{toxinidir}/test_requirements_py3x.txt + py{34,35,36,37}: -r{toxinidir}/test_requirements_py3x.txt commands = python -m pytest -sx tests --cov gunicorn_thrift --cov-report term-missing