Additional error handling

pull/1/head
Mark Veidemanis 3 years ago
parent f28e42c42f
commit 3340b6d4da
Signed by: m
GPG Key ID: 5ACFCEED46C0904F

@ -49,6 +49,9 @@ class Agora(object):
""" """
dash = self.agora.dashboard_seller() dash = self.agora.dashboard_seller()
dash_tmp = [] dash_tmp = []
if "data" not in dash["response"].keys():
self.log.error("Data not in dashboard response: {content}", content=dash)
return False
if dash["response"]["data"]["contact_count"] > 0: if dash["response"]["data"]["contact_count"] > 0:
for contact in dash["response"]["data"]["contact_list"]: for contact in dash["response"]["data"]["contact_list"]:
contact_id = contact["data"]["contact_id"] contact_id = contact["data"]["contact_id"]
@ -69,7 +72,6 @@ class Agora(object):
return False return False
if dash["response"]["data"]["contact_count"] > 0: if dash["response"]["data"]["contact_count"] > 0:
for contact in dash["response"]["data"]["contact_list"]: for contact in dash["response"]["data"]["contact_list"]:
print(f"CONTACT {contact}")
contact_id = contact["data"]["contact_id"] contact_id = contact["data"]["contact_id"]
current_trades.append(contact_id) current_trades.append(contact_id)
buyer = contact["data"]["buyer"]["username"] buyer = contact["data"]["buyer"]["username"]
@ -101,6 +103,7 @@ class Agora(object):
dash = self.agora.dashboard_seller() dash = self.agora.dashboard_seller()
dash_tmp = [] dash_tmp = []
if "data" not in dash["response"]: if "data" not in dash["response"]:
self.log.error("Data not in dashboard response: {content}", content=dash)
return False return False
if dash["response"]["data"]["contact_count"] > 0: if dash["response"]["data"]["contact_count"] > 0:
for contact in dash["response"]["data"]["contact_list"]: for contact in dash["response"]["data"]["contact_list"]:
@ -147,6 +150,8 @@ class Agora(object):
:rtype: dict with lists :rtype: dict with lists
""" """
dash = self.dashboard_id_only() dash = self.dashboard_id_only()
if dash is None:
return False
messages_tmp = {} messages_tmp = {}
for contact_id in dash: for contact_id in dash:
messages = self.get_messages(contact_id, send_irc=send_irc) messages = self.get_messages(contact_id, send_irc=send_irc)

@ -184,6 +184,7 @@ class Revolut(object):
if r.status_code == 200: if r.status_code == 200:
return r.json() return r.json()
else: else:
self.log.error("Error getting accounts: {content}", content=r.content)
return False return False
def get_total_usd(self): def get_total_usd(self):

@ -52,11 +52,17 @@ class Transactions(object):
txid = inside["id"] txid = inside["id"]
txtype = inside["type"] txtype = inside["type"]
state = inside["state"] state = inside["state"]
if "reference" in inside:
reference = inside["reference"] reference = inside["reference"]
else:
reference = "not_given"
leg = inside["legs"][0] leg = inside["legs"][0]
if "counterparty" in leg:
account_type = leg["counterparty"]["account_type"] account_type = leg["counterparty"]["account_type"]
else:
account_type = "not_given"
amount = leg["amount"] amount = leg["amount"]
currency = leg["currency"] currency = leg["currency"]

Loading…
Cancel
Save