Re-use requests.auth.HTTPDigestAuth between requests

Fixes: #104
pull/105/head
/dev/null 2 years ago
parent 59953f6f81
commit 83e3f2a12a

@ -18,6 +18,7 @@ install:
- pip install dist/*.tar.gz # install dependencies as specified in setup.py
- pip install -r test_requirements_py`echo $TRAVIS_PYTHON_VERSION | cut -f 1 -d .`.txt
script:
- black --check .
- pytest
after_success:
- coveralls

@ -91,3 +91,9 @@ Development
.. code-block:: bash
.venv/bin/pytest
6. Format your code with black
.. code-block:: bash
.venv/bin/black .

@ -106,8 +106,7 @@ class JSONRPCDaemon(object):
protocol=protocol, host=host, port=port
)
_log.debug("JSONRPC daemon backend URL: {url}".format(url=self.url))
self.user = user
self.password = password
self.auth = requests.auth.HTTPDigestAuth(user, password)
self.timeout = timeout
self.verify_ssl_certs = verify_ssl_certs
self.proxies = {protocol: proxy_url}
@ -222,12 +221,11 @@ class JSONRPCDaemon(object):
path=path, data=json.dumps(data, indent=2, sort_keys=True)
)
)
auth = requests.auth.HTTPDigestAuth(self.user, self.password)
rsp = requests.post(
self.url + path,
headers=hdr,
data=json.dumps(data) if data else None,
auth=auth,
auth=self.auth,
timeout=self.timeout,
verify=self.verify_ssl_certs,
proxies=self.proxies,
@ -251,12 +249,11 @@ class JSONRPCDaemon(object):
method=method, params=json.dumps(params, indent=2, sort_keys=True)
)
)
auth = requests.auth.HTTPDigestAuth(self.user, self.password)
rsp = requests.post(
self.url + "/json_rpc",
headers=hdr,
data=json.dumps(data),
auth=auth,
auth=self.auth,
timeout=self.timeout,
verify=self.verify_ssl_certs,
proxies=self.proxies,

@ -50,8 +50,7 @@ class JSONRPCWallet(object):
protocol=protocol, host=host, port=port
)
_log.debug("JSONRPC wallet backend URL: {url}".format(url=self.url))
self.user = user
self.password = password
self.auth = requests.auth.HTTPDigestAuth(user, password)
self.timeout = timeout
self.verify_ssl_certs = verify_ssl_certs
self.proxies = {protocol: proxy_url}
@ -386,12 +385,11 @@ class JSONRPCWallet(object):
method=method, params=json.dumps(params, indent=2, sort_keys=True)
)
)
auth = requests.auth.HTTPDigestAuth(self.user, self.password)
rsp = requests.post(
self.url,
headers=hdr,
data=json.dumps(data),
auth=auth,
auth=self.auth,
timeout=self.timeout,
verify=self.verify_ssl_certs,
proxies=self.proxies,

@ -1,3 +1,4 @@
black==21.11b1
coverage~=5.3
coveralls~=2.1
pip>=9

Loading…
Cancel
Save