From bf20f634b3c2a9b677f10a130618a41cc539487d Mon Sep 17 00:00:00 2001 From: lza_menace Date: Sun, 13 Dec 2020 14:51:06 -0800 Subject: [PATCH] simple bypass for soft failure --- wowstash/library/cache.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/wowstash/library/cache.py b/wowstash/library/cache.py index 8e457af..1099215 100644 --- a/wowstash/library/cache.py +++ b/wowstash/library/cache.py @@ -32,17 +32,20 @@ class Cache(object): } headers = {'accept': 'application/json'} url = 'https://api.coingecko.com/api/v3/coins/wownero' - r = r_get(url, headers=headers, data=data) - info = { - 'genesis_date': r.json()['genesis_date'], - 'market_cap_rank': r.json()['market_cap_rank'], - 'current_price': r.json()['market_data']['current_price']['usd'], - 'market_cap': r.json()['market_data']['market_cap']['usd'], - 'market_cap_rank': r.json()['market_data']['market_cap_rank'], - 'total_volume': r.json()['market_data']['total_volume']['usd'], - 'last_updated': r.json()['last_updated'] - } - self.store_data("coin_info", 15, json_dumps(info)) - return info + try: + r = r_get(url, headers=headers, data=data) + info = { + 'genesis_date': r.json()['genesis_date'], + 'market_cap_rank': r.json()['market_cap_rank'], + 'current_price': r.json()['market_data']['current_price']['usd'], + 'market_cap': r.json()['market_data']['market_cap']['usd'], + 'market_cap_rank': r.json()['market_data']['market_cap_rank'], + 'total_volume': r.json()['market_data']['total_volume']['usd'], + 'last_updated': r.json()['last_updated'] + } + self.store_data("coin_info", 15, json_dumps(info)) + return info + except: + return {} cache = Cache()