Skip to content

Commit

Permalink
[tests] use python3 for authproxy.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jnewbery committed Oct 17, 2017
1 parent 2c66cea commit fc0176d
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions test/functional/test_framework/authproxy.py
Expand Up @@ -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"

Expand All @@ -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


Expand All @@ -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:
Expand All @@ -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):
Expand All @@ -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)
Expand Down

0 comments on commit fc0176d

Please sign in to comment.