Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
    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)
Exemplo n.º 4
0
 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)
Exemplo n.º 5
0
def _get_request_headers(uri):
    server = urlparse.urlparse(uri)[0:2]
    if server in _request_headers:
        return _request_headers[server]

    headers = rpc_client_lib.authorization_headers(getpass.getuser(), uri)
    headers['Content-Type'] = 'application/json'

    _request_headers[server] = headers
    return headers
Exemplo n.º 6
0
def _get_request_headers(uri):
    server = urlparse.urlparse(uri)[0:2]
    if server in _request_headers:
        return _request_headers[server]

    headers = rpc_client_lib.authorization_headers(getpass.getuser(), uri)
    headers['Content-Type'] = 'application/json'

    _request_headers[server] = headers
    return headers
Exemplo n.º 7
0
def _get_request_headers(uri):
    # ParseResult is subscriptable, ignore E1136
    server = urlparse.urlparse(uri)[0:2]    # pylint: disable=E1136
    if server in _request_headers:
        return _request_headers[server]

    headers = rpc_client_lib.authorization_headers(getpass.getuser(), uri)
    headers['Content-Type'] = 'application/json'

    _request_headers[server] = headers
    return headers
Exemplo n.º 8
0
def _get_request_headers(uri):
    # ParseResult is subscriptable, ignore E1136
    server = urllib.parse.urlparse(uri)[0:2]    # pylint: disable=E1136
    if server in _request_headers:
        return _request_headers[server]

    headers = rpc_client_lib.authorization_headers(getpass.getuser(), uri)
    headers['Content-Type'] = 'application/json'

    _request_headers[server] = headers
    return headers