From fc0176d01e57c0f512d6a8adf4d50df356121b02 Mon Sep 17 00:00:00 2001 From: John Newbery Date: Mon, 17 Jul 2017 13:09:04 -0400 Subject: [PATCH] [tests] use python3 for authproxy.py --- test/functional/test_framework/authproxy.py | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/test/functional/test_framework/authproxy.py b/test/functional/test_framework/authproxy.py index 747bda309c552..8b2f31624a505 100644 --- a/test/functional/test_framework/authproxy.py +++ b/test/functional/test_framework/authproxy.py @@ -33,20 +33,14 @@ - 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 @@ def __init__(self, rpc_error): 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 @@ def __init__(self, service_url, service_name=None, timeout=HTTP_TIMEOUT, connect 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 @@ def __init__(self, service_url, service_name=None, timeout=HTTP_TIMEOUT, connect # 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 @@ def _request(self, method, path, postdata): 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)