def main(): args = parse() args_dict = dict(args.__dict__) logsetup(args_dict) try: # create thrift client with client_context(tracelogs_thrift.TraceLogService, args.thrift_server, args.thrift_port, proto_factory=TCyBinaryProtocolFactory(), trans_factory=TCyBufferedTransportFactory() ) as thrift_client: client = TracesThriftClientController(client=thrift_client, module=tracelogs_thrift) output = client.dispatchCall(args.command, args) print output except thriftpy.thrift.TException as ex: logger.error('Thrift error: %s' % ex.message) except socket_error as sex: logger.error('Network error: %s' % sex) except Exception as ex: logger.error('Application error: %s' % ex) raise
print "Starting thrift server on %s:%s..." % (host, port) try: server = make_server( tracelogs_thrift.TraceLogService, TracesThriftServerController(module=tracelogs_thrift), host, port, proto_factory=TCyBinaryProtocolFactory(), trans_factory=TCyBufferedTransportFactory() ) server.serve() except thriftpy.thrift.TException as ex: logger.error('Thrift error: %s' % ex.message) except socket_error as sex: logger.error('Network error: %s' % sex) except Exception as ex: logger.error('Application error: %s' % ex) raise if __name__ == '__main__': logsetup() do_serve(config.thrift.get('host'), config.thrift.get('port'))