From e022f7b154c2ebaf82c42596e9cc77ca01b1b74a Mon Sep 17 00:00:00 2001 From: gryf Date: Wed, 14 Feb 2024 07:39:04 +0100 Subject: [PATCH] Handle connection errors --- pywmcurrencies/pywmcurrencies.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pywmcurrencies/pywmcurrencies.py b/pywmcurrencies/pywmcurrencies.py index 621180d..583b72f 100755 --- a/pywmcurrencies/pywmcurrencies.py +++ b/pywmcurrencies/pywmcurrencies.py @@ -168,7 +168,8 @@ class SensorDockApp(wmdocklib.DockApp): time.sleep(0.1) def get_rate_string(self, currency): - self._get_rates() + if not self._get_rates(): + return 'ERROR' previous, current = self._data[currency] @@ -220,6 +221,7 @@ class SensorDockApp(wmdocklib.DockApp): previous, current = [x['mid'] for x in result.get('rates', [])][-2:] self._data[currency] = (previous, current) + return True def _switch_graph(self): currencies = self.conf.get('currencies')