Python thrift.transport.THttpClient.THttpClient() Examples

The following are 30 code examples of thrift.transport.THttpClient.THttpClient(). 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.transport.THttpClient , or try the search function .
Example #1
Source File: __init__.py    From opencensus-python with Apache License 2.0 6 votes vote down vote up
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 #2
Source File: thrift_connection.py    From lightstep-tracer-python with MIT License 6 votes vote down vote up
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 #3
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 #4
Source File: session.py    From line-py with BSD 3-Clause "New" or "Revised" License 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 #5
Source File: session.py    From line-py with BSD 3-Clause "New" or "Revised" License 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 #6
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 #7
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 #8
Source File: session.py    From sb 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 #9
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 #10
Source File: Talk.py    From linezx with MIT License 5 votes vote down vote up
def createTransport(path=None, update_headers=None, service=None):
    Headers = {
        'User-Agent': con.USER_AGENT,
        'X-Line-Application': con.APP_NAME,
        "x-lal": "ja-US_US",
    }
    Headers.update({"x-lpqs" : path})
    if(update_headers is not None):
        Headers.update(update_headers)
    transport = THttpClient.THttpClient(con.LINE_HOST_DOMAIN + path)
    transport.setCustomHeaders(Headers)
    protocol = TCompactProtocol.TCompactProtocol(transport)
    client = service(protocol)
    return client 
Example #11
Source File: Talk.py    From linezx with MIT License 5 votes vote down vote up
def __init__(self):
    Config.__init__(self)
    self.transport = THttpClient.THttpClient(self.LINE_HOST_DOMAIN,None, self.LINE_API_QUERY_PATH_FIR)
    self.transport.setCustomHeaders({
      "X-Line-Application" : self.APP_NAME,"User-Agent" : self.USER_AGENT})
    self.transport.open()
    self.protocol = TCompactProtocol.TCompactProtocol(self.transport);
    self.client = TalkService.Client(self.protocol) 
Example #12
Source File: channel.py    From linezx with MIT License 5 votes vote down vote up
def __init__(self, authToken,mid):
        Config.__init__(self)
        self.mid = mid
        self.authToken = authToken
        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.transport.open()
        self.protocol = TCompactProtocol.TCompactProtocol(self.transport)
        self.client = ChannelService.Client(self.protocol)

        self.transport.path = self.LINE_CHAN_QUERY_PATH 
Example #13
Source File: Poll.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 = TalkService.Client(self.protocol)
    self.rev = self.client.getLastOpRevision()
    self.transport.path = self.LINE_POLL_QUERY_PATH_FIR
    self.transport.open() 
Example #14
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 #15
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 #16
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 #17
Source File: session.py    From line-py with BSD 3-Clause "New" or "Revised" License 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 #18
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 #19
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 #20
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 #21
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 #22
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 #23
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 #24
Source File: __init__.py    From opentelemetry-python with Apache License 2.0 5 votes vote down vote up
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 #25
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 #26
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 #27
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 #28
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 #29
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 #30
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()