Python thrift.protocol.TCompactProtocol.TCompactProtocol() Examples

The following are 30 code examples of thrift.protocol.TCompactProtocol.TCompactProtocol(). 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.TCompactProtocol , or try the search function .
Example #1
Source File: test_thrift.py    From jaeger-client-python with Apache License 2.0 6 votes vote down vote up
def _marshall_span(span):
    class TestTrans(TMemoryBuffer):
        def now_reading(self):
            """
            Thrift TMemoryBuffer is not read-able AND write-able,
            it's one or the other (really? yes.). This will convert
            us from write-able to read-able.
            """
            self._buffer = BytesIO(self.getvalue())

    batch = thrift.make_jaeger_batch(
        spans=[span], process=ttypes.Process(serviceName='x', tags={}))

    # write and read them to test encoding
    args = Agent.emitBatch_args(batch)
    t = TestTrans()
    prot = TCompactProtocol(t)
    args.write(prot)
    t.now_reading()
    args.read(prot) 
Example #2
Source File: session.py    From SOLO with GNU General Public License v3.0 5 votes vote down vote up
def Channel(self, isopen=True):
        self.transport = THttpClient.THttpClient(self.host)
        self.transport.setCustomHeaders(self.headers)

        self.protocol = TCompactProtocol.TCompactProtocol(self.transport)
        self._channel  = ChannelService.Client(self.protocol)
        
        if isopen:
            self.transport.open()

        return self._channel 
Example #3
Source File: LineApi.py    From BotProtectLine with GNU General Public License v3.0 5 votes vote down vote up
def _transportOpen(self, host, path=None):
        if path is not None:
            self._thriftTransport = LineTransport(host + path)
        else:
            self._thriftTransport = LineTransport(host)
        self._thriftProtocol = TCompactProtocol.TCompactProtocol(
            self._thriftTransport)
        self._client = TalkService.Client(self._thriftProtocol) 
Example #4
Source File: flume.py    From openslack-crawler with Apache License 2.0 5 votes vote down vote up
def __init__(self, thrift_host, thrift_port, timeout=None, unix_socket=None):
        self._transObj = _Transport(thrift_host, thrift_port, timeout=timeout, unix_socket=unix_socket)
        self._protocol = TCompactProtocol.TCompactProtocol(trans=self._transObj.get_transport())
        self.client = ThriftSourceProtocol.Client(iprot=self._protocol, oprot=self._protocol)
        self._transObj.connect() 
Example #5
Source File: call.py    From linezx with MIT License 5 votes vote down vote up
def __init__(self, authToken):
       Config.__init__(self)
       self.transport = THttpClient.THttpClient(self.LINE_HOST_DOMAIN, None, self.LINE_API_QUERY_PATH_FIR)
       self.transport.path = self.LINE_AUTH_QUERY_PATH
       self.transport.setCustomHeaders({"X-Line-Application" : self.APP_NAME,"User-Agent" : self.USER_AGENT,"X-Line-Access": authToken})
       self.protocol = TCompactProtocol.TCompactProtocol(self.transport);
       self.client = CallService.Client(self.protocol)
       self.transport.path = self.LINE_CALL_QUERY_PATH
       self.transport.open() 
Example #6
Source File: reporter.py    From jaeger-client-python with Apache License 2.0 5 votes vote down vote up
def getProtocol(self, transport):
        """
        Implements Thrift ProtocolFactory interface
        :param: transport:
        :return: Thrift compact protocol
        """
        return TCompactProtocol.TCompactProtocol(transport) 
Example #7
Source File: session.py    From sb with GNU General Public License v3.0 5 votes vote down vote up
def Channel(self, isopen=True):
        self.transport = THttpClient.THttpClient(self.host)
        self.transport.setCustomHeaders(self.headers)

        self.protocol = TCompactProtocol.TCompactProtocol(self.transport)
        self._channel  = ChannelService.Client(self.protocol)
        
        if isopen:
            self.transport.open()

        return self._channel 
Example #8
Source File: session.py    From sb with GNU General Public License v3.0 5 votes vote down vote up
def Talk(self, isopen=True):
        self.transport = THttpClient.THttpClient(self.host)
        self.transport.setCustomHeaders(self.headers)
        
        self.protocol = TCompactProtocol.TCompactProtocol(self.transport)
        self._talk  = TalkService.Client(self.protocol)
        
        if isopen:
            self.transport.open()

        return self._talk 
Example #9
Source File: session.py    From sb with GNU General Public License v3.0 5 votes vote down vote up
def Auth(self, isopen=True):
        self.transport = THttpClient.THttpClient(self.host)
        self.transport.setCustomHeaders(self.headers)
        
        self.protocol = TCompactProtocol.TCompactProtocol(self.transport)
        self._auth  = AuthService.Client(self.protocol)
        
        if isopen:
            self.transport.open()

        return self._auth 
Example #10
Source File: __init__.py    From opencensus-python with Apache License 2.0 5 votes vote down vote up
def __init__(
            self,
            host_name=DEFAULT_HOST_NAME,
            port=DEFAULT_AGENT_PORT,
            max_packet_size=UDP_PACKET_MAX_LENGTH,
            client=agent.Client,
            transport=sync.SyncTransport):
        self.transport = transport(self)
        self.address = (host_name, port)
        self.max_packet_size = max_packet_size
        self.buffer = TTransport.TMemoryBuffer()
        self.client = client(
            iprot=TCompactProtocol.TCompactProtocol(trans=self.buffer)) 
Example #11
Source File: session.py    From sb with GNU General Public License v3.0 5 votes vote down vote up
def Call(self, isopen=True):
        self.transport = THttpClient.THttpClient(self.host)
        self.transport.setCustomHeaders(self.headers)

        self.protocol = TCompactProtocol.TCompactProtocol(self.transport)
        self._call  = CallService.Client(self.protocol)
        
        if isopen:
            self.transport.open()

        return self._call 
Example #12
Source File: session.py    From prankpy3 with GNU General Public License v3.0 5 votes vote down vote up
def Call(self, isopen=True):
        self.transport = THttpClient.THttpClient(self.host)
        self.transport.setCustomHeaders(self.headers)

        self.protocol = TCompactProtocol.TCompactProtocol(self.transport)
        self._call  = CallService.Client(self.protocol)
        
        # if isopen:
        #     self.transport.open()

        return self._call 
Example #13
Source File: session.py    From prankpy3 with GNU General Public License v3.0 5 votes vote down vote up
def Channel(self, isopen=True):
        self.transport = THttpClient.THttpClient(self.host)
        self.transport.setCustomHeaders(self.headers)

        self.protocol = TCompactProtocol.TCompactProtocol(self.transport)
        self._channel  = ChannelService.Client(self.protocol)
        
        # if isopen:
        #     self.transport.open()

        return self._channel 
Example #14
Source File: session.py    From prankpy3 with GNU General Public License v3.0 5 votes vote down vote up
def Talk(self, isopen=True):
        self.transport = THttpClient.THttpClient(self.host)
        self.transport.setCustomHeaders(self.headers)
        
        self.protocol = TCompactProtocol.TCompactProtocol(self.transport)
        self._talk  = TalkService.Client(self.protocol)
        
        # if isopen:
        #     self.transport.open()

        return self._talk 
Example #15
Source File: session.py    From SOLO with GNU General Public License v3.0 5 votes vote down vote up
def Square(self, isopen=True):
        self.transport = THttpClient.THttpClient(self.host)
        self.transport.setCustomHeaders(self.headers)

        self.protocol = TCompactProtocol.TCompactProtocol(self.transport)
        self._square  = SquareService.Client(self.protocol)
        
        if isopen:
            self.transport.open()

        return self._square 
Example #16
Source File: session.py    From SOLO with GNU General Public License v3.0 5 votes vote down vote up
def Call(self, isopen=True):
        self.transport = THttpClient.THttpClient(self.host)
        self.transport.setCustomHeaders(self.headers)

        self.protocol = TCompactProtocol.TCompactProtocol(self.transport)
        self._call  = CallService.Client(self.protocol)
        
        if isopen:
            self.transport.open()

        return self._call 
Example #17
Source File: session.py    From prankpy3 with GNU General Public License v3.0 5 votes vote down vote up
def Square(self, isopen=True):
        self.transport = THttpClient.THttpClient(self.host)
        self.transport.setCustomHeaders(self.headers)

        self.protocol = TCompactProtocol.TCompactProtocol(self.transport)
        #self._square  = SquareService.Client(self.protocol)
        
        # if isopen:
        #     self.transport.open()

        #return self._square 
Example #18
Source File: session.py    From SOLO with GNU General Public License v3.0 5 votes vote down vote up
def Talk(self, isopen=True):
        self.transport = THttpClient.THttpClient(self.host)
        self.transport.setCustomHeaders(self.headers)
        
        self.protocol = TCompactProtocol.TCompactProtocol(self.transport)
        self._talk  = TalkService.Client(self.protocol)
        
        if isopen:
            self.transport.open()

        return self._talk 
Example #19
Source File: session.py    From SOLO with GNU General Public License v3.0 5 votes vote down vote up
def Auth(self, isopen=True):
        self.transport = THttpClient.THttpClient(self.host)
        self.transport.setCustomHeaders(self.headers)
        
        self.protocol = TCompactProtocol.TCompactProtocol(self.transport)
        self._auth  = AuthService.Client(self.protocol)
        
        if isopen:
            self.transport.open()

        return self._auth 
Example #20
Source File: auth.py    From AsyncLine with MIT License 5 votes vote down vote up
def loginWithQrcode(self, path=None):
		self.url(config.MAIN_PATH)
		qr = await self.call('getAuthQrcode', True, "AsyncLine", "")
		p_key = generate_asymmetric_keypair()
		secret_query = create_secret_query(p_key.public_key)
		print(f"line://au/q/{qr.verifier}?secret={secret_query}&e2eeVersion=1")
		r = self.waitForPhoneConfirm(qr.verifier)
		vr = r.json()
	
		key_chain = vr['result']['metadata']['encryptedKeyChain']
		public_key = vr['result']['metadata']['publicKey']
		data_key = decrypt_keychain(p_key, key_chain, public_key)
		keychain = E2EEKeyChain()
		tbuffer = TMemoryBuffer(data_key)
		protocol = TCompactProtocol(tbuffer)
		keychain.read(protocol)
		
		self.url(config.AUTH_PATH)
		rq = LoginRequest(
			type=LoginType.QRCODE,
			identityProvider=IdentityProvider.LINE,
			keepLoggedIn=True,
			accessLocation=config.LOGIN_LOCATION,
			systemName="AsyncLine",
			verifier=vr["result"]["verifier"],
			secret=p_key.public_key,
			e2eeVersion=2
		)
		lr = await self.call('loginZ', rq)
		self.updateHeaders({
			'X-Line-Access': lr.authToken
		})
		self.authToken = lr.authToken
		self.cert = lr.certificate
		if path:
			with open(path, "w") as fp:
				fp.write(lr.authToken)
		await self.afterLogin() 
Example #21
Source File: __init__.py    From opentelemetry-python with Apache License 2.0 5 votes vote down vote up
def __init__(
        self,
        host_name,
        port,
        max_packet_size=UDP_PACKET_MAX_LENGTH,
        client=agent.Client,
    ):
        self.address = (host_name, port)
        self.max_packet_size = max_packet_size
        self.buffer = TTransport.TMemoryBuffer()
        self.client = client(
            iprot=TCompactProtocol.TCompactProtocol(trans=self.buffer)
        ) 
Example #22
Source File: session.py    From ajs2 with GNU General Public License v3.0 5 votes vote down vote up
def Square(self, isopen=True):
        self.transport = THttpClient.THttpClient(self.host)
        self.transport.setCustomHeaders(self.headers)

        self.protocol = TCompactProtocol.TCompactProtocol(self.transport)
        self._square  = SquareService.Client(self.protocol)
        
        if isopen:
            self.transport.open()

        return self._square 
Example #23
Source File: session.py    From ajs2 with GNU General Public License v3.0 5 votes vote down vote up
def Call(self, isopen=True):
        self.transport = THttpClient.THttpClient(self.host)
        self.transport.setCustomHeaders(self.headers)

        self.protocol = TCompactProtocol.TCompactProtocol(self.transport)
        self._call  = CallService.Client(self.protocol)
        
        if isopen:
            self.transport.open()

        return self._call 
Example #24
Source File: session.py    From ajs2 with GNU General Public License v3.0 5 votes vote down vote up
def Channel(self, isopen=True):
        self.transport = THttpClient.THttpClient(self.host)
        self.transport.setCustomHeaders(self.headers)

        self.protocol = TCompactProtocol.TCompactProtocol(self.transport)
        self._channel  = ChannelService.Client(self.protocol)
        
        if isopen:
            self.transport.open()

        return self._channel 
Example #25
Source File: session.py    From ajs2 with GNU General Public License v3.0 5 votes vote down vote up
def Talk(self, isopen=True):
        self.transport = THttpClient.THttpClient(self.host)
        self.transport.setCustomHeaders(self.headers)
        
        self.protocol = TCompactProtocol.TCompactProtocol(self.transport)
        self._talk  = TalkService.Client(self.protocol)
        
        if isopen:
            self.transport.open()

        return self._talk 
Example #26
Source File: session.py    From ajs2 with GNU General Public License v3.0 5 votes vote down vote up
def Auth(self, isopen=True):
        self.transport = THttpClient.THttpClient(self.host)
        self.transport.setCustomHeaders(self.headers)
        
        self.protocol = TCompactProtocol.TCompactProtocol(self.transport)
        self._auth  = AuthService.Client(self.protocol)
        
        if isopen:
            self.transport.open()

        return self._auth 
Example #27
Source File: Poll.py    From vipro2 with MIT License 5 votes vote down vote up
def __init__(self, authToken):
    self.transport = THttpClient.THttpClient('https://gd2.line.naver.jp:443'+ self.http_query_path)
    self.transport.setCustomHeaders({
      "User-Agent" : self.UA,
      "X-Line-Application" : self.LA,
      "X-Line-Access": authToken
    });
    self.protocol = TCompactProtocol.TCompactProtocol(self.transport);
    self.client = LineService.Client(self.protocol)
    self.rev = self.client.getLastOpRevision()
    self.transport.path = self.polling_path
    self.transport.open() 
Example #28
Source File: channel.py    From vipro2 with MIT License 5 votes vote down vote up
def __init__(self, authToken):
        self.authToken = authToken
        self.transport = THttpClient.THttpClient('https://gd2.line.naver.jp:443'+self.http_query_path)
        self.transport.setCustomHeaders({ "User-Agent" : self.UA,
        "X-Line-Application" : self.LA,
        "X-Line-Access": self.authToken
        })
        self.transport.open()
        self.protocol = TCompactProtocol.TCompactProtocol(self.transport)
        self.client = LineService.Client(self.protocol)
        self.mid = self.client.getProfile().mid
        self.transport.path = self.channel_query_path 
Example #29
Source File: Talk.py    From vipro2 with MIT License 5 votes vote down vote up
def __init__(self):
    self.transport = THttpClient.THttpClient('https://gd2.line.naver.jp:443'+self.auth_query_path)
    self.transport.setCustomHeaders({
      "User-Agent" : self.UA,
      "X-Line-Application" : self.LA,
    })
    self.transport.open()
    self.protocol = TCompactProtocol.TCompactProtocol(self.transport);
    self.client = LineService.Client(self.protocol) 
Example #30
Source File: session.py    From final with GNU General Public License v3.0 5 votes vote down vote up
def Square(self, isopen=True):
        self.transport = THttpClient.THttpClient(self.host)
        self.transport.setCustomHeaders(self.headers)
        self.protocol = TCompactProtocol.TCompactProtocol(self.transport)
        self._square  = SquareService.Client(self.protocol)
        if isopen:
            self.transport.open()
        return self._square