From f434bac45a43ee612f9ba9513585d22e1aff640a Mon Sep 17 00:00:00 2001 From: Michael Wozniak Date: Fri, 7 Mar 2014 22:51:58 -0500 Subject: [PATCH 1/2] fix bug for 0 transaction wallet 0 transaction wallet would return an error when getting transaction list --- plugins/exchange_rate.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/exchange_rate.py b/plugins/exchange_rate.py index b8e00629..91d195ca 100644 --- a/plugins/exchange_rate.py +++ b/plugins/exchange_rate.py @@ -344,8 +344,11 @@ class Plugin(BasePlugin): def history_tab_update(self): if self.config.get('history_rates', 'unchecked') == "checked": tx_list = self.tx_list - - mintimestr = datetime.datetime.fromtimestamp(int(min(tx_list.items(), key=lambda x: x[1]['timestamp'])[1]['timestamp'])).strftime('%Y-%m-%d') + + try: + mintimestr = datetime.datetime.fromtimestamp(int(min(tx_list.items(), key=lambda x: x[1]['timestamp'])[1]['timestamp'])).strftime('%Y-%m-%d') + except ValueError: + return maxtimestr = datetime.datetime.now().strftime('%Y-%m-%d') try: resp_hist = self.exchanger.get_json('api.coindesk.com', "/v1/bpi/historical/close.json?start=" + mintimestr + "&end=" + maxtimestr) From 2fc3f408c821b5d19bfebb835e182e8d4cdadc56 Mon Sep 17 00:00:00 2001 From: Michael Wozniak Date: Fri, 7 Mar 2014 23:10:36 -0500 Subject: [PATCH 2/2] Exception caused by tx_list not defined I wasn't seeing this before, so I assume it could be a race condition if the "load_wallet" function doesn't finish before the history tab is updated. --- plugins/exchange_rate.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/exchange_rate.py b/plugins/exchange_rate.py index 91d195ca..84447693 100644 --- a/plugins/exchange_rate.py +++ b/plugins/exchange_rate.py @@ -343,8 +343,11 @@ class Plugin(BasePlugin): def history_tab_update(self): if self.config.get('history_rates', 'unchecked') == "checked": - tx_list = self.tx_list - + try: + tx_list = self.tx_list + except Exception: + return + try: mintimestr = datetime.datetime.fromtimestamp(int(min(tx_list.items(), key=lambda x: x[1]['timestamp'])[1]['timestamp'])).strftime('%Y-%m-%d') except ValueError: