Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions cardano/backends/walletrest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ def default(self, o):
class WalletREST(object):
base_url = None
timeout = 10
verify=None
cert=None

ERR2EXCEPTION = {
403: {
Expand All @@ -45,25 +47,29 @@ class WalletREST(object):
},
}

def __init__(self, protocol="http", host="localhost", port=8090):
def __init__(self, protocol="http", host="localhost", port=8090, verify=None, cert=None):
self.base_url = "{protocol}://{host}:{port}/v2/".format(
protocol=protocol, host=host, port=port
)
self.verify=verify
self.cert=cert
_log.debug("WalletREST backend url: {:s}".format(self.base_url))

def raw_request(self, method, path, params=None):
def raw_request(self, method, path, params=None, verify=None, cert=None):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems this method doesn't use the new keywords

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yikes, seems like I need to get some sleep.
I'll take a look at this (and other comments) tomorrow with fresh eyes and will re-submit.
Thanks for fast review!

url = "".join([self.base_url, path])
hdr = {"Content-Type": "application/json"}
params = params or {}
_log.debug(
u"{method} {url}\nParams:\n{params}".format(
method=method,
url=url,
verify=verify,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These aren't used in the resulting message

cert=cert,
params=json.dumps(params, indent=2, sort_keys=True),
)
)
rsp = getattr(requests, method.lower())(
url, headers=hdr, data=json.dumps(params), timeout=self.timeout
url, headers=hdr, data=json.dumps(params), timeout=self.timeout, verify=self.verify, cert=self.cert
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kwargs are dropped but instead values from self. are used (which is right)

)
if rsp.status_code != 204: # if content exists
result = rsp.json(parse_float=Decimal)
Expand Down