# # Autogenerated by Thrift Compiler (0.11.0) # # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING # # options string: py # 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 thrift.Thrift import TProcessor from thrift.transport import TTransport all_structs = [] class Iface(object): def commentSum(self, cid): """ 查询单个cid弹幕数 Parameters: - cid """ pass def commentSumList(self, cids): """ * 批量查询多个cid弹幕数 * Parameters: - cids """ pass def download(self, cids, fileName): """ * 批量下载弹幕 * Parameters: - cids - fileName """ 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 commentSum(self, cid): """ 查询单个cid弹幕数 Parameters: - cid """ self.send_commentSum(cid) return self.recv_commentSum() def send_commentSum(self, cid): self._oprot.writeMessageBegin('commentSum', TMessageType.CALL, self._seqid) args = commentSum_args() args.cid = cid args.write(self._oprot) self._oprot.writeMessageEnd() self._oprot.trans.flush() def recv_commentSum(self): iprot = self._iprot (fname, mtype, rseqid) = iprot.readMessageBegin() if mtype == TMessageType.EXCEPTION: x = TApplicationException() x.read(iprot) iprot.readMessageEnd() raise x result = commentSum_result() result.read(iprot) iprot.readMessageEnd() if result.success is not None: return result.success raise TApplicationException(TApplicationException.MISSING_RESULT, "commentSum failed: unknown result") def commentSumList(self, cids): """ * 批量查询多个cid弹幕数 * Parameters: - cids """ self.send_commentSumList(cids) return self.recv_commentSumList() def send_commentSumList(self, cids): self._oprot.writeMessageBegin('commentSumList', TMessageType.CALL, self._seqid) args = commentSumList_args() args.cids = cids args.write(self._oprot) self._oprot.writeMessageEnd() self._oprot.trans.flush() def recv_commentSumList(self): iprot = self._iprot (fname, mtype, rseqid) = iprot.readMessageBegin() if mtype == TMessageType.EXCEPTION: x = TApplicationException() x.read(iprot) iprot.readMessageEnd() raise x result = commentSumList_result() result.read(iprot) iprot.readMessageEnd() if result.success is not None: return result.success raise TApplicationException(TApplicationException.MISSING_RESULT, "commentSumList failed: unknown result") def download(self, cids, fileName): """ * 批量下载弹幕 * Parameters: - cids - fileName """ self.send_download(cids, fileName) return self.recv_download() def send_download(self, cids, fileName): self._oprot.writeMessageBegin('download', TMessageType.CALL, self._seqid) args = download_args() args.cids = cids args.fileName = fileName args.write(self._oprot) self._oprot.writeMessageEnd() self._oprot.trans.flush() def recv_download(self): iprot = self._iprot (fname, mtype, rseqid) = iprot.readMessageBegin() if mtype == TMessageType.EXCEPTION: x = TApplicationException() x.read(iprot) iprot.readMessageEnd() raise x result = download_result() result.read(iprot) iprot.readMessageEnd() if result.success is not None: return result.success raise TApplicationException(TApplicationException.MISSING_RESULT, "download failed: unknown result") class Processor(Iface, TProcessor): def __init__(self, handler): self._handler = handler self._processMap = {} self._processMap["commentSum"] = Processor.process_commentSum self._processMap["commentSumList"] = Processor.process_commentSumList self._processMap["download"] = Processor.process_download 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_commentSum(self, seqid, iprot, oprot): args = commentSum_args() args.read(iprot) iprot.readMessageEnd() result = commentSum_result() try: result.success = self._handler.commentSum(args.cid) 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("commentSum", msg_type, seqid) result.write(oprot) oprot.writeMessageEnd() oprot.trans.flush() def process_commentSumList(self, seqid, iprot, oprot): args = commentSumList_args() args.read(iprot) iprot.readMessageEnd() result = commentSumList_result() try: result.success = self._handler.commentSumList(args.cids) 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("commentSumList", msg_type, seqid) result.write(oprot) oprot.writeMessageEnd() oprot.trans.flush() def process_download(self, seqid, iprot, oprot): args = download_args() args.read(iprot) iprot.readMessageEnd() result = download_result() try: result.success = self._handler.download(args.cids, args.fileName) 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("download", msg_type, seqid) result.write(oprot) oprot.writeMessageEnd() oprot.trans.flush() # HELPER FUNCTIONS AND STRUCTURES class commentSum_args(object): """ Attributes: - cid """ def __init__(self, cid=None,): self.cid = cid 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.cid = 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('commentSum_args') if self.cid is not None: oprot.writeFieldBegin('cid', TType.I32, 1) oprot.writeI32(self.cid) 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(commentSum_args) commentSum_args.thrift_spec = ( None, # 0 (1, TType.I32, 'cid', None, None, ), # 1 ) class commentSum_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.I32: self.success = 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('commentSum_result') if self.success is not None: oprot.writeFieldBegin('success', TType.I32, 0) oprot.writeI32(self.success) 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(commentSum_result) commentSum_result.thrift_spec = ( (0, TType.I32, 'success', None, None, ), # 0 ) class commentSumList_args(object): """ Attributes: - cids """ def __init__(self, cids=None,): self.cids = cids 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.LIST: self.cids = [] (_etype3, _size0) = iprot.readListBegin() for _i4 in range(_size0): _elem5 = iprot.readI32() self.cids.append(_elem5) iprot.readListEnd() 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('commentSumList_args') if self.cids is not None: oprot.writeFieldBegin('cids', TType.LIST, 1) oprot.writeListBegin(TType.I32, len(self.cids)) for iter6 in self.cids: oprot.writeI32(iter6) oprot.writeListEnd() 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(commentSumList_args) commentSumList_args.thrift_spec = ( None, # 0 (1, TType.LIST, 'cids', (TType.I32, None, False), None, ), # 1 ) class commentSumList_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.LIST: self.success = [] (_etype10, _size7) = iprot.readListBegin() for _i11 in range(_size7): _elem12 = iprot.readI32() self.success.append(_elem12) iprot.readListEnd() 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('commentSumList_result') if self.success is not None: oprot.writeFieldBegin('success', TType.LIST, 0) oprot.writeListBegin(TType.I32, len(self.success)) for iter13 in self.success: oprot.writeI32(iter13) oprot.writeListEnd() 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(commentSumList_result) commentSumList_result.thrift_spec = ( (0, TType.LIST, 'success', (TType.I32, None, False), None, ), # 0 ) class download_args(object): """ Attributes: - cids - fileName """ def __init__(self, cids=None, fileName=None,): self.cids = cids self.fileName = fileName 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.LIST: self.cids = [] (_etype17, _size14) = iprot.readListBegin() for _i18 in range(_size14): _elem19 = iprot.readI32() self.cids.append(_elem19) iprot.readListEnd() else: iprot.skip(ftype) elif fid == 2: if ftype == TType.STRING: self.fileName = 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('download_args') if self.cids is not None: oprot.writeFieldBegin('cids', TType.LIST, 1) oprot.writeListBegin(TType.I32, len(self.cids)) for iter20 in self.cids: oprot.writeI32(iter20) oprot.writeListEnd() oprot.writeFieldEnd() if self.fileName is not None: oprot.writeFieldBegin('fileName', TType.STRING, 2) oprot.writeString(self.fileName.encode('utf-8') if sys.version_info[0] == 2 else self.fileName) 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(download_args) download_args.thrift_spec = ( None, # 0 (1, TType.LIST, 'cids', (TType.I32, None, False), None, ), # 1 (2, TType.STRING, 'fileName', 'UTF8', None, ), # 2 ) class download_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.STRING: self.success = 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('download_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() 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(download_result) download_result.thrift_spec = ( (0, TType.STRING, 'success', 'UTF8', None, ), # 0 ) fix_spec(all_structs) del all_structs