| # |
| # Autogenerated by Thrift |
| # |
| # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING |
| # |
| |
| from thrift.Thrift import * |
| import sys |
| from ttypes import * |
| from thrift.Thrift import TProcessor |
| from thrift.transport import TTransport |
| from thrift.protocol import TBinaryProtocol |
| try: |
| from thrift.protocol import fastbinary |
| except: |
| fastbinary = None |
| |
| |
| class Iface: |
| def execute(self, functionName, funcArgs): |
| """ |
| Parameters: |
| - functionName |
| - funcArgs |
| """ |
| pass |
| |
| def result(self, id, result): |
| """ |
| Parameters: |
| - id |
| - result |
| """ |
| pass |
| |
| |
| class Client(Iface): |
| def __init__(self, iprot, oprot=None): |
| self._iprot = self._oprot = iprot |
| if oprot != None: |
| self._oprot = oprot |
| self._seqid = 0 |
| |
| def execute(self, functionName, funcArgs): |
| """ |
| Parameters: |
| - functionName |
| - funcArgs |
| """ |
| self.send_execute(functionName, funcArgs) |
| return self.recv_execute() |
| |
| def send_execute(self, functionName, funcArgs): |
| self._oprot.writeMessageBegin('execute', TMessageType.CALL, self._seqid) |
| args = execute_args() |
| args.functionName = functionName |
| args.funcArgs = funcArgs |
| args.write(self._oprot) |
| self._oprot.writeMessageEnd() |
| self._oprot.trans.flush() |
| |
| def recv_execute(self, ): |
| (fname, mtype, rseqid) = self._iprot.readMessageBegin() |
| if mtype == TMessageType.EXCEPTION: |
| x = TApplicationException() |
| x.read(self._iprot) |
| self._iprot.readMessageEnd() |
| raise x |
| result = execute_result() |
| result.read(self._iprot) |
| self._iprot.readMessageEnd() |
| if result.success != None: |
| return result.success |
| raise TApplicationException(TApplicationException.MISSING_RESULT, "execute failed: unknown result"); |
| |
| def result(self, id, result): |
| """ |
| Parameters: |
| - id |
| - result |
| """ |
| self.send_result(id, result) |
| self.recv_result() |
| |
| def send_result(self, id, result): |
| self._oprot.writeMessageBegin('result', TMessageType.CALL, self._seqid) |
| args = result_args() |
| args.id = id |
| args.result = result |
| args.write(self._oprot) |
| self._oprot.writeMessageEnd() |
| self._oprot.trans.flush() |
| |
| def recv_result(self, ): |
| (fname, mtype, rseqid) = self._iprot.readMessageBegin() |
| if mtype == TMessageType.EXCEPTION: |
| x = TApplicationException() |
| x.read(self._iprot) |
| self._iprot.readMessageEnd() |
| raise x |
| result = result_result() |
| result.read(self._iprot) |
| self._iprot.readMessageEnd() |
| return |
| |
| |
| class Processor(Iface, TProcessor): |
| def __init__(self, handler): |
| self._handler = handler |
| self._processMap = {} |
| self._processMap["execute"] = Processor.process_execute |
| self._processMap["result"] = Processor.process_result |
| |
| 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_execute(self, seqid, iprot, oprot): |
| args = execute_args() |
| args.read(iprot) |
| iprot.readMessageEnd() |
| result = execute_result() |
| result.success = self._handler.execute(args.functionName, args.funcArgs) |
| oprot.writeMessageBegin("execute", TMessageType.REPLY, seqid) |
| result.write(oprot) |
| oprot.writeMessageEnd() |
| oprot.trans.flush() |
| |
| def process_result(self, seqid, iprot, oprot): |
| args = result_args() |
| args.read(iprot) |
| iprot.readMessageEnd() |
| result = result_result() |
| self._handler.result(args.id, args.result) |
| oprot.writeMessageBegin("result", TMessageType.REPLY, seqid) |
| result.write(oprot) |
| oprot.writeMessageEnd() |
| oprot.trans.flush() |
| |
| |
| # HELPER FUNCTIONS AND STRUCTURES |
| |
| class execute_args: |
| """ |
| Attributes: |
| - functionName |
| - funcArgs |
| """ |
| |
| thrift_spec = ( |
| None, # 0 |
| (1, TType.STRING, 'functionName', None, None, ), # 1 |
| (2, TType.STRING, 'funcArgs', None, None, ), # 2 |
| ) |
| |
| def __init__(self, functionName=None, funcArgs=None,): |
| self.functionName = functionName |
| self.funcArgs = funcArgs |
| |
| 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.functionName = iprot.readString().decode('utf-8'); |
| else: |
| iprot.skip(ftype) |
| elif fid == 2: |
| if ftype == TType.STRING: |
| self.funcArgs = 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('execute_args') |
| if self.functionName != None: |
| oprot.writeFieldBegin('functionName', TType.STRING, 1) |
| oprot.writeString(self.functionName.encode('utf-8')); |
| oprot.writeFieldEnd() |
| if self.funcArgs != None: |
| oprot.writeFieldBegin('funcArgs', TType.STRING, 2) |
| oprot.writeString(self.funcArgs.encode('utf-8')); |
| oprot.writeFieldEnd() |
| oprot.writeFieldStop() |
| oprot.writeStructEnd() |
| |
| 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 union_value(self): |
| d = self.__dict__ |
| for key in d: |
| val = d[key] |
| if not val is None: |
| return val |
| |
| def get_set_field(self): |
| for attr in self.__dict__: |
| if not self.__dict__[attr] is None: |
| return attr |
| |
| def get_set_field_id(self): |
| for idx, tup in enumerate(self.__class__.thrift_spec): |
| if tup: |
| key = tup[2] |
| if not self.__dict__[key] is None: |
| return idx |
| |
| class execute_result: |
| """ |
| Attributes: |
| - success |
| """ |
| |
| thrift_spec = ( |
| (0, TType.STRING, 'success', None, None, ), # 0 |
| ) |
| |
| def __init__(self, success=None,): |
| self.success = success |
| |
| 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) |
| 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('execute_result') |
| if self.success != None: |
| oprot.writeFieldBegin('success', TType.STRING, 0) |
| oprot.writeString(self.success.encode('utf-8')); |
| oprot.writeFieldEnd() |
| oprot.writeFieldStop() |
| oprot.writeStructEnd() |
| |
| 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 union_value(self): |
| d = self.__dict__ |
| for key in d: |
| val = d[key] |
| if not val is None: |
| return val |
| |
| def get_set_field(self): |
| for attr in self.__dict__: |
| if not self.__dict__[attr] is None: |
| return attr |
| |
| def get_set_field_id(self): |
| for idx, tup in enumerate(self.__class__.thrift_spec): |
| if tup: |
| key = tup[2] |
| if not self.__dict__[key] is None: |
| return idx |
| |
| class result_args: |
| """ |
| Attributes: |
| - id |
| - result |
| """ |
| |
| thrift_spec = ( |
| None, # 0 |
| (1, TType.STRING, 'id', None, None, ), # 1 |
| (2, TType.STRING, 'result', None, None, ), # 2 |
| ) |
| |
| def __init__(self, id=None, result=None,): |
| self.id = id |
| self.result = result |
| |
| 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.id = iprot.readString().decode('utf-8'); |
| else: |
| iprot.skip(ftype) |
| elif fid == 2: |
| if ftype == TType.STRING: |
| self.result = 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('result_args') |
| if self.id != None: |
| oprot.writeFieldBegin('id', TType.STRING, 1) |
| oprot.writeString(self.id.encode('utf-8')); |
| oprot.writeFieldEnd() |
| if self.result != None: |
| oprot.writeFieldBegin('result', TType.STRING, 2) |
| oprot.writeString(self.result.encode('utf-8')); |
| oprot.writeFieldEnd() |
| oprot.writeFieldStop() |
| oprot.writeStructEnd() |
| |
| 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 union_value(self): |
| d = self.__dict__ |
| for key in d: |
| val = d[key] |
| if not val is None: |
| return val |
| |
| def get_set_field(self): |
| for attr in self.__dict__: |
| if not self.__dict__[attr] is None: |
| return attr |
| |
| def get_set_field_id(self): |
| for idx, tup in enumerate(self.__class__.thrift_spec): |
| if tup: |
| key = tup[2] |
| if not self.__dict__[key] is None: |
| return idx |
| |
| class result_result: |
| |
| 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('result_result') |
| oprot.writeFieldStop() |
| oprot.writeStructEnd() |
| |
| 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 union_value(self): |
| d = self.__dict__ |
| for key in d: |
| val = d[key] |
| if not val is None: |
| return val |
| |
| def get_set_field(self): |
| for attr in self.__dict__: |
| if not self.__dict__[attr] is None: |
| return attr |
| |
| def get_set_field_id(self): |
| for idx, tup in enumerate(self.__class__.thrift_spec): |
| if tup: |
| key = tup[2] |
| if not self.__dict__[key] is None: |
| return idx |
| |
| |