[tests] fix flake8 warnings in authproxy.py
This commit is contained in:
parent
fc0176d01e
commit
323d8f61e9
1 changed files with 11 additions and 14 deletions
|
@ -42,9 +42,8 @@ import socket
|
||||||
import time
|
import time
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
|
|
||||||
USER_AGENT = "AuthServiceProxy/0.1"
|
|
||||||
|
|
||||||
HTTP_TIMEOUT = 30
|
HTTP_TIMEOUT = 30
|
||||||
|
USER_AGENT = "AuthServiceProxy/0.1"
|
||||||
|
|
||||||
log = logging.getLogger("BitcoinRPC")
|
log = logging.getLogger("BitcoinRPC")
|
||||||
|
|
||||||
|
@ -92,11 +91,9 @@ class AuthServiceProxy(object):
|
||||||
# Callables re-use the connection of the original proxy
|
# Callables re-use the connection of the original proxy
|
||||||
self.__conn = connection
|
self.__conn = connection
|
||||||
elif self.__url.scheme == 'https':
|
elif self.__url.scheme == 'https':
|
||||||
self.__conn = http.client.HTTPSConnection(self.__url.hostname, port,
|
self.__conn = http.client.HTTPSConnection(self.__url.hostname, port, timeout=timeout)
|
||||||
timeout=timeout)
|
|
||||||
else:
|
else:
|
||||||
self.__conn = http.client.HTTPConnection(self.__url.hostname, port,
|
self.__conn = http.client.HTTPConnection(self.__url.hostname, port, timeout=timeout)
|
||||||
timeout=timeout)
|
|
||||||
|
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
if name.startswith('__') and name.endswith('__'):
|
if name.startswith('__') and name.endswith('__'):
|
||||||
|
@ -125,7 +122,7 @@ class AuthServiceProxy(object):
|
||||||
return self._get_response()
|
return self._get_response()
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
except (BrokenPipeError,ConnectionResetError):
|
except (BrokenPipeError, ConnectionResetError):
|
||||||
# Python 3.5+ raises BrokenPipeError instead of BadStatusLine when the connection was reset
|
# Python 3.5+ raises BrokenPipeError instead of BadStatusLine when the connection was reset
|
||||||
# ConnectionResetError happens on FreeBSD with Python 3.4
|
# ConnectionResetError happens on FreeBSD with Python 3.4
|
||||||
self.__conn.close()
|
self.__conn.close()
|
||||||
|
@ -135,7 +132,7 @@ class AuthServiceProxy(object):
|
||||||
def get_request(self, *args, **argsn):
|
def get_request(self, *args, **argsn):
|
||||||
AuthServiceProxy.__id_count += 1
|
AuthServiceProxy.__id_count += 1
|
||||||
|
|
||||||
log.debug("-%s-> %s %s"%(AuthServiceProxy.__id_count, self._service_name,
|
log.debug("-%s-> %s %s" % (AuthServiceProxy.__id_count, self._service_name,
|
||||||
json.dumps(args, default=EncodeDecimal, ensure_ascii=self.ensure_ascii)))
|
json.dumps(args, default=EncodeDecimal, ensure_ascii=self.ensure_ascii)))
|
||||||
if args and argsn:
|
if args and argsn:
|
||||||
raise ValueError('Cannot handle both named and positional arguments')
|
raise ValueError('Cannot handle both named and positional arguments')
|
||||||
|
@ -157,7 +154,7 @@ class AuthServiceProxy(object):
|
||||||
|
|
||||||
def batch(self, rpc_call_list):
|
def batch(self, rpc_call_list):
|
||||||
postdata = json.dumps(list(rpc_call_list), default=EncodeDecimal, ensure_ascii=self.ensure_ascii)
|
postdata = json.dumps(list(rpc_call_list), default=EncodeDecimal, ensure_ascii=self.ensure_ascii)
|
||||||
log.debug("--> "+postdata)
|
log.debug("--> " + postdata)
|
||||||
return self._request('POST', self.__url.path, postdata.encode('utf-8'))
|
return self._request('POST', self.__url.path, postdata.encode('utf-8'))
|
||||||
|
|
||||||
def _get_response(self):
|
def _get_response(self):
|
||||||
|
@ -184,9 +181,9 @@ class AuthServiceProxy(object):
|
||||||
response = json.loads(responsedata, parse_float=decimal.Decimal)
|
response = json.loads(responsedata, parse_float=decimal.Decimal)
|
||||||
elapsed = time.time() - req_start_time
|
elapsed = time.time() - req_start_time
|
||||||
if "error" in response and response["error"] is None:
|
if "error" in response and response["error"] is None:
|
||||||
log.debug("<-%s- [%.6f] %s"%(response["id"], elapsed, json.dumps(response["result"], default=EncodeDecimal, ensure_ascii=self.ensure_ascii)))
|
log.debug("<-%s- [%.6f] %s" % (response["id"], elapsed, json.dumps(response["result"], default=EncodeDecimal, ensure_ascii=self.ensure_ascii)))
|
||||||
else:
|
else:
|
||||||
log.debug("<-- [%.6f] %s"%(elapsed,responsedata))
|
log.debug("<-- [%.6f] %s" % (elapsed, responsedata))
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def __truediv__(self, relative_uri):
|
def __truediv__(self, relative_uri):
|
||||||
|
|
Loading…
Reference in a new issue