def _connect(self, rpc_path): # This does not fail even if the address is wrong. # We need to wait for an actual RPC to fail headers = rpc_client_lib.authorization_headers(self.username, self.web_server) rpc_server = self.web_server + rpc_path return rpc_client_lib.get_proxy(rpc_server, headers=headers)
def __init__(self, path, user, server, print_log, debug, reply_debug): """ Create a cached instance of a connection to the frontend user: username to connect as server: frontend server to connect to print_log: pring a logging message to stdout on every operation debug: print out all RPC traffic """ if not user: user = getpass.getuser() if not server: if 'AUTOTEST_WEB' in os.environ: server = os.environ['AUTOTEST_WEB'] else: server = settings.get_value('SERVER', 'hostname', default=DEFAULT_SERVER) self.server = server self.user = user self.print_log = print_log self.debug = debug self.reply_debug = reply_debug http_server = 'http://' + server headers = rpc_client_lib.authorization_headers(user, http_server) rpc_server = http_server + path if debug: print 'SERVER: %s' % rpc_server print 'HEADERS: %s' % headers self.proxy = rpc_client_lib.get_proxy(rpc_server, headers=headers)