diff options
author | John Newbery <john@johnnewbery.com> | 2017-07-17 13:09:04 -0400 |
---|---|---|
committer | John Newbery <john@johnnewbery.com> | 2017-10-16 21:45:49 -0400 |
commit | fc0176d01e57c0f512d6a8adf4d50df356121b02 (patch) | |
tree | a0525363e4c228546d9e00993516226bbbf6df91 /test | |
parent | 2c66cea2d18682de1eef544fc3b74a1487a1741c (diff) |
[tests] use python3 for authproxy.py
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/test_framework/authproxy.py | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/test/functional/test_framework/authproxy.py b/test/functional/test_framework/authproxy.py index 747bda309c..8b2f31624a 100644 --- a/test/functional/test_framework/authproxy.py +++ b/test/functional/test_framework/authproxy.py @@ -33,20 +33,14 @@ ServiceProxy class: - uses standard Python json lib """ -try: - import http.client as httplib -except ImportError: - import httplib import base64 import decimal +import http.client import json import logging import socket import time -try: - import urllib.parse as urlparse -except ImportError: - import urlparse +import urllib.parse USER_AGENT = "AuthServiceProxy/0.1" @@ -60,7 +54,7 @@ class JSONRPCException(Exception): errmsg = '%(message)s (%(code)i)' % rpc_error except (KeyError, TypeError): errmsg = '' - Exception.__init__(self, errmsg) + super().__init__(errmsg) self.error = rpc_error @@ -77,7 +71,7 @@ class AuthServiceProxy(object): self.__service_url = service_url self._service_name = service_name self.ensure_ascii = ensure_ascii # can be toggled on the fly by tests - self.__url = urlparse.urlparse(service_url) + self.__url = urllib.parse.urlparse(service_url) if self.__url.port is None: port = 80 else: @@ -98,10 +92,10 @@ class AuthServiceProxy(object): # Callables re-use the connection of the original proxy self.__conn = connection elif self.__url.scheme == 'https': - self.__conn = httplib.HTTPSConnection(self.__url.hostname, port, + self.__conn = http.client.HTTPSConnection(self.__url.hostname, port, timeout=timeout) else: - self.__conn = httplib.HTTPConnection(self.__url.hostname, port, + self.__conn = http.client.HTTPConnection(self.__url.hostname, port, timeout=timeout) def __getattr__(self, name): @@ -124,7 +118,7 @@ class AuthServiceProxy(object): try: self.__conn.request(method, path, postdata, headers) return self._get_response() - except httplib.BadStatusLine as e: + except http.client.BadStatusLine as e: if e.line == "''": # if connection was closed, try again self.__conn.close() self.__conn.request(method, path, postdata, headers) |