socket_error = (transport.TTransportException, socket.error, protocol.cybin.ProtocolError) else: socket_error = (transport.TTransportException, socket.error) # from thriftpy2.rpc import make_client from .thrift_connector import HeartbeatClientPool, ThriftPyClient from .api import * from .utils import get_mac_address thrift_path = path.join(sys.modules["ROOT_DIR"], "jqdata.thrift") thrift_path = path.abspath(thrift_path) module_name = path.splitext(path.basename(thrift_path))[0] thrift = None with open(thrift_path) as f: thrift = thriftpy.load_fp(f, "jqdata_thrift") class JQDataClient(object): _threading_local = threading.local() _auth_params = {} @classmethod def instance(cls): _instance = getattr(cls._threading_local, '_instance', None) if _instance is None: if cls._auth_params: _instance = JQDataClient(**cls._auth_params) cls._threading_local._instance = _instance return _instance
import msgpack import thriftpy2 as thriftpy from thriftpy2 import transport, protocol if platform.system().lower() != "windows": socket_error = (transport.TTransportException, socket.error, protocol.cybin.ProtocolError) else: socket_error = (transport.TTransportException, socket.error) from thriftpy2.rpc import make_client thrift_path = path.join(sys.modules["ROOT_DIR"], "simons.thrift") thrift_path = path.abspath(thrift_path) module_name = path.splitext(path.basename(thrift_path))[0] thrift = None with open(thrift_path) as f: simons_thrift = thriftpy.load_fp(f, "simons_thrift") class SimonsClient(object): _threading_local = threading.local() _auth_params = {} @classmethod def instance(cls): _instance = getattr(cls._threading_local, '_instance', None) if _instance is None: if cls._auth_params: _instance = SimonsClient(**cls._auth_params) cls._threading_local._instance = _instance return _instance
2: HBPulse pulse, 3: bool boolval, 4: HBRecords records, 5: HBNodes nodes, 7: optional binary message_blob; } struct HBMessage { 1: HBServerMessageType type, 2: HBMessageData data, 3: optional i32 message_id = -1, } exception HBAuthorizationException { 1: required string msg; } exception HBExecutionException { 1: required string msg; } """ storm_thrift = thriftpy2.load_fp(io.StringIO(_THRIFT_STR), module_name="storm_thrift") # Fix a lovely issue where GlobalStreamIds didn't have consistent hash values storm_thrift.GlobalStreamId.__hash__ = lambda self: (hash(self.componentId) ^ hash(self.streamId)) # Import everything so it's actually available within this module from storm_thrift import *
# Copyright (c) JoinQuant Development Team api_description = """ enum DataType { Serial = 1, DataFrame = 2, Panel = 3 } struct St_Query_Rsp { 1:required bool status, 2:optional string msg, 5:optional string error } struct St_Query_Req { 1:required string method_name, 2:required binary params, } service JqDataService { St_Query_Rsp query(1:St_Query_Req rsp), St_Query_Rsp auth(1:string username, 2:string password, 5:bool compress, 8:string mac, 10:string version), St_Query_Rsp auth_by_token(1: string token) } """ import six import thriftpy2 as thriftpy thrift = thriftpy.load_fp(six.StringIO(api_description), "jqdata_thrift")
def bootstrap(self): bootstrap_thrift = thriftpy2.load_fp(io.StringIO(self.BOOTSTRAP_THRIFT), 'satori_bootstrap_thrift') bootstrap_client = self.make_client(bootstrap_thrift.Server) self.satori_thrift = thriftpy2.load_fp(io.StringIO(bootstrap_client.Server_getIDL(self.token)), 'satori_thrift')