Skip to content

Commit 323d8f6

Browse files
committed
[tests] fix flake8 warnings in authproxy.py
1 parent fc0176d commit 323d8f6

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

test/functional/test_framework/authproxy.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@
4242
import time
4343
import urllib.parse
4444

45-
USER_AGENT = "AuthServiceProxy/0.1"
46-
4745
HTTP_TIMEOUT = 30
46+
USER_AGENT = "AuthServiceProxy/0.1"
4847

4948
log = logging.getLogger("BitcoinRPC")
5049

@@ -70,7 +69,7 @@ class AuthServiceProxy(object):
7069
def __init__(self, service_url, service_name=None, timeout=HTTP_TIMEOUT, connection=None, ensure_ascii=True):
7170
self.__service_url = service_url
7271
self._service_name = service_name
73-
self.ensure_ascii = ensure_ascii # can be toggled on the fly by tests
72+
self.ensure_ascii = ensure_ascii # can be toggled on the fly by tests
7473
self.__url = urllib.parse.urlparse(service_url)
7574
if self.__url.port is None:
7675
port = 80
@@ -92,11 +91,9 @@ def __init__(self, service_url, service_name=None, timeout=HTTP_TIMEOUT, connect
9291
# Callables re-use the connection of the original proxy
9392
self.__conn = connection
9493
elif self.__url.scheme == 'https':
95-
self.__conn = http.client.HTTPSConnection(self.__url.hostname, port,
96-
timeout=timeout)
94+
self.__conn = http.client.HTTPSConnection(self.__url.hostname, port, timeout=timeout)
9795
else:
98-
self.__conn = http.client.HTTPConnection(self.__url.hostname, port,
99-
timeout=timeout)
96+
self.__conn = http.client.HTTPConnection(self.__url.hostname, port, timeout=timeout)
10097

10198
def __getattr__(self, name):
10299
if name.startswith('__') and name.endswith('__'):
@@ -119,13 +116,13 @@ def _request(self, method, path, postdata):
119116
self.__conn.request(method, path, postdata, headers)
120117
return self._get_response()
121118
except http.client.BadStatusLine as e:
122-
if e.line == "''": # if connection was closed, try again
119+
if e.line == "''": # if connection was closed, try again
123120
self.__conn.close()
124121
self.__conn.request(method, path, postdata, headers)
125122
return self._get_response()
126123
else:
127124
raise
128-
except (BrokenPipeError,ConnectionResetError):
125+
except (BrokenPipeError, ConnectionResetError):
129126
# Python 3.5+ raises BrokenPipeError instead of BadStatusLine when the connection was reset
130127
# ConnectionResetError happens on FreeBSD with Python 3.4
131128
self.__conn.close()
@@ -135,8 +132,8 @@ def _request(self, method, path, postdata):
135132
def get_request(self, *args, **argsn):
136133
AuthServiceProxy.__id_count += 1
137134

138-
log.debug("-%s-> %s %s"%(AuthServiceProxy.__id_count, self._service_name,
139-
json.dumps(args, default=EncodeDecimal, ensure_ascii=self.ensure_ascii)))
135+
log.debug("-%s-> %s %s" % (AuthServiceProxy.__id_count, self._service_name,
136+
json.dumps(args, default=EncodeDecimal, ensure_ascii=self.ensure_ascii)))
140137
if args and argsn:
141138
raise ValueError('Cannot handle both named and positional arguments')
142139
return {'version': '1.1',
@@ -157,7 +154,7 @@ def __call__(self, *args, **argsn):
157154

158155
def batch(self, rpc_call_list):
159156
postdata = json.dumps(list(rpc_call_list), default=EncodeDecimal, ensure_ascii=self.ensure_ascii)
160-
log.debug("--> "+postdata)
157+
log.debug("--> " + postdata)
161158
return self._request('POST', self.__url.path, postdata.encode('utf-8'))
162159

163160
def _get_response(self):
@@ -184,9 +181,9 @@ def _get_response(self):
184181
response = json.loads(responsedata, parse_float=decimal.Decimal)
185182
elapsed = time.time() - req_start_time
186183
if "error" in response and response["error"] is None:
187-
log.debug("<-%s- [%.6f] %s"%(response["id"], elapsed, json.dumps(response["result"], default=EncodeDecimal, ensure_ascii=self.ensure_ascii)))
184+
log.debug("<-%s- [%.6f] %s" % (response["id"], elapsed, json.dumps(response["result"], default=EncodeDecimal, ensure_ascii=self.ensure_ascii)))
188185
else:
189-
log.debug("<-- [%.6f] %s"%(elapsed,responsedata))
186+
log.debug("<-- [%.6f] %s" % (elapsed, responsedata))
190187
return response
191188

192189
def __truediv__(self, relative_uri):

0 commit comments

Comments
 (0)