Python thrift.protocol.TBinaryProtocol.TBinaryProtocol() Examples
The following are 16
code examples of thrift.protocol.TBinaryProtocol.TBinaryProtocol().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
thrift.protocol.TBinaryProtocol
, or try the search function
.
Example #1
Source File: thrift_connection.py From lightstep-tracer-python with MIT License | 6 votes |
def open(self): """Establish HTTP connection to the server. Note: THttpClient also supports https and will use http/https according to the scheme in the URL it is given. """ self._lock.acquire() try: self._transport = THttpClient.THttpClient(self._collector_url) self._transport.open() protocol = TBinaryProtocol.TBinaryProtocol(self._transport) self._client = ReportingService.Client(protocol) except Thrift.TException: self._open_exceptions_count += 1 else: self.ready = True finally: self._lock.release() # May throw an Exception on failure.
Example #2
Source File: __init__.py From opencensus-python with Apache License 2.0 | 6 votes |
def __init__( self, thrift_url='', auth=None, client=jaeger.Client, transport=sync.SyncTransport, http_transport=THttpClient.THttpClient): self.transport = transport(self) self.thrift_url = thrift_url self.auth = auth self.http_transport = http_transport(uri_or_host=thrift_url) self.client = client( iprot=TBinaryProtocol.TBinaryProtocol(trans=self.http_transport)) # set basic auth header if auth is not None: import base64 auth_header = '{}:{}'.format(*auth) decoded = base64.b64encode(auth_header.encode()).decode('ascii') basic_auth = dict(Authorization='Basic {}'.format(decoded)) self.http_transport.setCustomHeaders(basic_auth)
Example #3
Source File: putget_test.py From cassandra-dtest with Apache License 2.0 | 5 votes |
def __init__(self, node=None, host=None, port=None, ks_name='ks', cf_name='cf', cassandra_interface='11'): """ initializes the connection. - node: a ccm node. If supplied, the host and port, and cassandra_interface will be pulled from the node. - host, port: overwritten if node is supplied - ks_name, cf_name: all operations are done on the supplied ks and cf - cassandra_interface: '07' and '11' are currently supported. This is the thrift interface to cassandra. '11' suffices for now except when creating keyspaces against cassandra0.7, in which case 07 must be used. """ if node: host, port = node.network_interfaces['thrift'] self.node = node self.host = host self.port = port self.cassandra_interface = cassandra_interface # import the correct version of the cassandra thrift interface # and set self.Cassandra as the imported module module_name = 'cassandra-thrift.v%s' % cassandra_interface imp = __import__(module_name, globals(), locals(), ['Cassandra']) self.Cassandra = imp.Cassandra socket = TSocket.TSocket(host, port) self.transport = TTransport.TFramedTransport(socket) protocol = TBinaryProtocol.TBinaryProtocol(self.transport) self.client = self.Cassandra.Client(protocol) socket.open() self.open_socket = True self.ks_name = ks_name self.cf_name = cf_name
Example #4
Source File: thrift_test.py From cassandra-dtest with Apache License 2.0 | 5 votes |
def get_thrift_client(host='127.0.0.1', port=9160): socket = TSocket.TSocket(host, port) transport = TTransport.TFramedTransport(socket) protocol = TBinaryProtocol.TBinaryProtocol(transport) client = Cassandra.Client(protocol) client.transport = transport return client
Example #5
Source File: client.py From dispel4py with Apache License 2.0 | 5 votes |
def __init__(self, host, port): self.host = host self.port = port transport = TSocket.TSocket(host, port) self.transport = TTransport.TFramedTransport(transport) self.protocol = TBinaryProtocol.TBinaryProtocol(self.transport) self.client = Nimbus.Client(self.protocol)
Example #6
Source File: python3_thrift_hbase2.py From Learning_Python with MIT License | 5 votes |
def connectHBase(): ''' 连接远程HBase :return: 连接HBase的客户端实例 ''' # thrift默认端口是9090 socket = TSocket.TSocket('10.0.86.245',9090) # 10.0.86.245是master结点ip socket.setTimeout(5000) transport = TTransport.TBufferedTransport(socket) protocol = TBinaryProtocol.TBinaryProtocol(transport) client = Hbase.Client(protocol) socket.open() return client
Example #7
Source File: python3_thrift_hbase2(paper_creator_aff_try).py From Learning_Python with MIT License | 5 votes |
def connectHBase(): ''' 连接远程HBase :return: 连接HBase的客户端实例 ''' # thrift默认端口是9090 socket = TSocket.TSocket('10.0.86.245',9090) # 10.0.86.245是master结点ip socket.setTimeout(5000) transport = TTransport.TBufferedTransport(socket) protocol = TBinaryProtocol.TBinaryProtocol(transport) client = Hbase.Client(protocol) socket.open() return client
Example #8
Source File: scannerGet.py From Learning_Python with MIT License | 5 votes |
def connectHBase(): ''' 连接远程HBase :return: 连接HBase的客户端实例 ''' # thrift默认端口是9090 socket = TSocket.TSocket('10.0.86.245',9090) # 10.0.86.245是master结点ip socket.setTimeout(5000) transport = TTransport.TBufferedTransport(socket) protocol = TBinaryProtocol.TBinaryProtocol(transport) client = Hbase.Client(protocol) socket.open() return client
Example #9
Source File: __init__.py From forsun with MIT License | 5 votes |
def connect(self): self.transport = TSocket(self.host, self.port) self.transport = TBufferedTransport(self.transport) protocol = TBinaryProtocol(self.transport) self.client = Client(protocol) self.transport.open()
Example #10
Source File: client.py From web_develop with GNU General Public License v3.0 | 5 votes |
def get_client(): transport = TSocket.TSocket('localhost', 8200) transport = TTransport.TBufferedTransport(transport) protocol = TBinaryProtocol.TBinaryProtocol(transport) client = PasteFileService.Client(protocol) transport.open() return client
Example #11
Source File: __init__.py From opentelemetry-python with Apache License 2.0 | 5 votes |
def __init__(self, thrift_url="", auth=None): self.thrift_url = thrift_url self.auth = auth self.http_transport = THttpClient.THttpClient( uri_or_host=self.thrift_url ) self.protocol = TBinaryProtocol.TBinaryProtocol(self.http_transport) # set basic auth header if auth is not None: auth_header = "{}:{}".format(*auth) decoded = base64.b64encode(auth_header.encode()).decode("ascii") basic_auth = dict(Authorization="Basic {}".format(decoded)) self.http_transport.setCustomHeaders(basic_auth)
Example #12
Source File: test_printer.py From thrift-tools with Apache License 2.0 | 5 votes |
def options(): return MessageSnifferOptions( iface=None, port=9090, ip=None, pcap_file=get_pcap_path('calc-service-binary'), protocol=TBinaryProtocol, finagle_thrift=False, read_values=True, max_queued=2000, max_message_size=2000, debug=False)
Example #13
Source File: thrift_message.py From thrift-tools with Apache License 2.0 | 5 votes |
def detect_protocol(cls, data, default=None): """ TODO: support fbthrift, finagle-thrift, finagle-mux, CORBA """ if cls.is_compact_protocol(data): return TCompactProtocol elif cls.is_binary_protocol(data): return TBinaryProtocol elif cls.is_json_protocol(data): return TJSONProtocol if default is None: raise ValueError('Unknown protocol') return default
Example #14
Source File: client.py From hazelcast-python-client with Apache License 2.0 | 5 votes |
def __init__(self, host, port): try: # Make socket transport = TSocket.TSocket(host=host, port=port) # Buffering is critical. Raw sockets are very slow transport = TTransport.TBufferedTransport(transport) # Wrap in a protocol protocol = TBinaryProtocol.TBinaryProtocol(transport) self.remote_controller = RemoteController.Client(protocol) # Connect! transport.open() except Thrift.TException as tx: self.logger.warn('%s' % tx.message)
Example #15
Source File: hive.py From airflow with Apache License 2.0 | 4 votes |
def get_metastore_client(self): """ Returns a Hive thrift client. """ import hmsclient from thrift.transport import TSocket, TTransport from thrift.protocol import TBinaryProtocol conn = self._find_valid_server() if not conn: raise AirflowException("Failed to locate the valid server.") auth_mechanism = conn.extra_dejson.get('authMechanism', 'NOSASL') if conf.get('core', 'security') == 'kerberos': auth_mechanism = conn.extra_dejson.get('authMechanism', 'GSSAPI') kerberos_service_name = conn.extra_dejson.get('kerberos_service_name', 'hive') conn_socket = TSocket.TSocket(conn.host, conn.port) if conf.get('core', 'security') == 'kerberos' \ and auth_mechanism == 'GSSAPI': try: import saslwrapper as sasl except ImportError: import sasl def sasl_factory(): sasl_client = sasl.Client() sasl_client.setAttr("host", conn.host) sasl_client.setAttr("service", kerberos_service_name) sasl_client.init() return sasl_client from thrift_sasl import TSaslClientTransport transport = TSaslClientTransport(sasl_factory, "GSSAPI", conn_socket) else: transport = TTransport.TBufferedTransport(conn_socket) protocol = TBinaryProtocol.TBinaryProtocol(transport) return hmsclient.HMSClient(iprot=protocol)
Example #16
Source File: sampleIDLapp.py From vmx-docker-lwaftr with Apache License 2.0 | 4 votes |
def Main(): parser = argparse.ArgumentParser(prog=os.path.basename(__file__), description='Sample JET application') parser.add_argument("--user", nargs='?', help="Username for authentication by JET server (default:%(default)s)", type=str, default=DEFAULT_JSD_USERNAME) parser.add_argument("--password", nargs='?', help="Password for authentication by JET server (default:%(default)s", type=str, default=DEFAULT_JSD_PASSWORD) parser.add_argument("--address", nargs='?', help="Address of the JSD server. (default: %(default)s)", type=str, default=DEFAULT_JSD_HOST) parser.add_argument("--port", nargs='?', help="Port number of the JSD request-response server. (default: %(default)s)", type=int, default=DEFAULT_JSD_PORT) parser.add_argument("--certificate", nargs='?', help="Certificate full path. (default: %(default)s)", type= str, default=DEFAULT_JSD_SSL_CERTIFICATE_PATH) args = parser.parse_args() try: # Make socket if (args.certificate is not None): # SSL connection if os.path.exists(args.certificate): transport = TSSLSocket.TSSLSocket(args.address, args.port, ca_certs=args.certificate) else: print('Certificate file %s does not exist' %(args.certificate)) raise Exception('Given certificate %s does not exist' %(args.certificate)) else: transport = TSocket.TSocket(args.address, args.port) # Buffering is critical. Raw sockets are very slow transport = TTransport.TBufferedTransport(transport) # Wrap in a protocol protocol = TBinaryProtocol.TBinaryProtocol(transport) mux_mgmt_protocol = TMultiplexedProtocol.TMultiplexedProtocol(protocol, "ManagementService") mux_route_protocol = TMultiplexedProtocol.TMultiplexedProtocol(protocol,"RouteService") transport.open() # IMPORTANT: The first service api to be called should be checkLogin mgmt_client = ManagementService.Client(mux_mgmt_protocol) result = mgmt_client.LoginCheck(args.user, args.password) if result is not True: raise ValueError('Login failed for User:%s' %args.user) print 'Invoked LoginCheck \nreturn = ', result print 'Requesting for mgmt tests' ManagementTests(mgmt_client, args.user, args.password) print 'Requesting for route tests' route_client = RouteService.Client(mux_route_protocol) RouteTests(route_client) except Exception as tx: print '%s' % (tx.message) return