Example #1
0
    def __init__(self, host, port, auto_handle_connection=True):
        # import only if necessary; some tests may not add this to PYTHONPATH
        from DBThriftAPI import CheckerReport

        transport = TTransport.TBufferedTransport(TSocket.TSocket(host, port))
        protocol = TBinaryProtocol.TBinaryProtocol(transport)
        client = CheckerReport.Client(protocol)
        super(CCReportHelper, self).__init__(transport, client,
                                             auto_handle_connection)
Example #2
0
    def __init__(self, host, port):
        """ Establish the connection between client and server. """

        tries_count = 0
        while True:
            try:
                self._transport = TSocket.TSocket(host, port)
                self._transport = TTransport.TBufferedTransport(
                    self._transport)
                self._protocol = TBinaryProtocol.TBinaryProtocol(
                    self._transport)
                self._client = CheckerReport.Client(self._protocol)
                self._transport.open()
                break

            except Thrift.TException as thrift_exc:
                if tries_count > 3:
                    LOG.error('The client cannot establish the connection '
                              'with the server!')
                    LOG.error('%s' % thrift_exc.message)
                    sys.exit(2)
                else:
                    tries_count += 1
                    time.sleep(1)