You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
246 lines
7.5 KiB
246 lines
7.5 KiB
7 years ago
|
#
|
||
|
# Autogenerated by Thrift Compiler (0.11.0)
|
||
|
#
|
||
|
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
|
||
|
#
|
||
|
# options string: py
|
||
|
#
|
||
|
import logging
|
||
|
|
||
|
from thrift.TRecursive import fix_spec
|
||
|
from thrift.Thrift import TProcessor
|
||
|
from thrift.Thrift import TType, TMessageType, TApplicationException
|
||
|
from thrift.transport import TTransport
|
||
|
|
||
|
from PixivSearch.thrift.TestQry.ttypes import QryResult
|
||
|
|
||
|
all_structs = []
|
||
|
|
||
|
class Iface(object):
|
||
|
def qryTest(self, qryCode):
|
||
|
"""
|
||
|
测试查询接口,当qryCode值为1时返回"成功"的响应信息,qryCode值为其他值时返回"失败"的响应信息
|
||
|
@param qryCode测试参数
|
||
|
|
||
|
Parameters:
|
||
|
- qryCode
|
||
|
"""
|
||
|
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 qryTest(self, qryCode):
|
||
|
"""
|
||
|
测试查询接口,当qryCode值为1时返回"成功"的响应信息,qryCode值为其他值时返回"失败"的响应信息
|
||
|
@param qryCode测试参数
|
||
|
|
||
|
Parameters:
|
||
|
- qryCode
|
||
|
"""
|
||
|
self.send_qryTest(qryCode)
|
||
|
return self.recv_qryTest()
|
||
|
|
||
|
def send_qryTest(self, qryCode):
|
||
|
self._oprot.writeMessageBegin('qryTest', TMessageType.CALL, self._seqid)
|
||
|
args = qryTest_args()
|
||
|
args.qryCode = qryCode
|
||
|
args.write(self._oprot)
|
||
|
self._oprot.writeMessageEnd()
|
||
|
self._oprot.trans.flush()
|
||
|
|
||
|
def recv_qryTest(self):
|
||
|
iprot = self._iprot
|
||
|
(fname, mtype, rseqid) = iprot.readMessageBegin()
|
||
|
if mtype == TMessageType.EXCEPTION:
|
||
|
x = TApplicationException()
|
||
|
x.read(iprot)
|
||
|
iprot.readMessageEnd()
|
||
|
raise x
|
||
|
result = qryTest_result()
|
||
|
result.read(iprot)
|
||
|
iprot.readMessageEnd()
|
||
|
if result.success is not None:
|
||
|
return result.success
|
||
|
raise TApplicationException(TApplicationException.MISSING_RESULT, "qryTest failed: unknown result")
|
||
|
|
||
|
|
||
|
class Processor(Iface, TProcessor):
|
||
|
def __init__(self, handler):
|
||
|
self._handler = handler
|
||
|
self._processMap = {}
|
||
|
self._processMap["qryTest"] = Processor.process_qryTest
|
||
|
|
||
|
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_qryTest(self, seqid, iprot, oprot):
|
||
|
args = qryTest_args()
|
||
|
args.read(iprot)
|
||
|
iprot.readMessageEnd()
|
||
|
result = qryTest_result()
|
||
|
try:
|
||
|
result.success = self._handler.qryTest(args.qryCode)
|
||
|
msg_type = TMessageType.REPLY
|
||
|
except TTransport.TTransportException:
|
||
|
raise
|
||
|
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("qryTest", msg_type, seqid)
|
||
|
result.write(oprot)
|
||
|
oprot.writeMessageEnd()
|
||
|
oprot.trans.flush()
|
||
|
|
||
|
# HELPER FUNCTIONS AND STRUCTURES
|
||
|
|
||
|
|
||
|
class qryTest_args(object):
|
||
|
"""
|
||
|
Attributes:
|
||
|
- qryCode
|
||
|
"""
|
||
|
|
||
|
|
||
|
def __init__(self, qryCode=None,):
|
||
|
self.qryCode = qryCode
|
||
|
|
||
|
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.I32:
|
||
|
self.qryCode = iprot.readI32()
|
||
|
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('qryTest_args')
|
||
|
if self.qryCode is not None:
|
||
|
oprot.writeFieldBegin('qryCode', TType.I32, 1)
|
||
|
oprot.writeI32(self.qryCode)
|
||
|
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(qryTest_args)
|
||
|
qryTest_args.thrift_spec = (
|
||
|
None, # 0
|
||
|
(1, TType.I32, 'qryCode', None, None, ), # 1
|
||
|
)
|
||
|
|
||
|
|
||
|
class qryTest_result(object):
|
||
|
"""
|
||
|
Attributes:
|
||
|
- success
|
||
|
"""
|
||
|
|
||
|
|
||
|
def __init__(self, success=None,):
|
||
|
self.success = success
|
||
|
|
||
|
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.STRUCT:
|
||
|
self.success = QryResult()
|
||
|
self.success.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('qryTest_result')
|
||
|
if self.success is not None:
|
||
|
oprot.writeFieldBegin('success', TType.STRUCT, 0)
|
||
|
self.success.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(qryTest_result)
|
||
|
qryTest_result.thrift_spec = (
|
||
|
(0, TType.STRUCT, 'success', [QryResult, None], None, ), # 0
|
||
|
)
|
||
|
fix_spec(all_structs)
|
||
|
del all_structs
|
||
|
|
||
|
|
||
|
|
||
|
|