From 17c13e6d8e4030847666411c87312a19cf9bb7f1 Mon Sep 17 00:00:00 2001 From: Ace Date: Sun, 23 Jun 2024 22:25:11 +0200 Subject: [PATCH] fix issue with yfinance --- inkycal/display/display.py | 2 +- inkycal/main.py | 14 +++++++++----- inkycal/modules/inkycal_stocks.py | 2 +- requirements.txt | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/inkycal/display/display.py b/inkycal/display/display.py index 179f71f..4eb47f3 100644 --- a/inkycal/display/display.py +++ b/inkycal/display/display.py @@ -197,7 +197,7 @@ class Display: >>> Display.get_display_names() """ - return supported_models.keys() + return list(supported_models.keys()) if __name__ == '__main__': diff --git a/inkycal/main.py b/inkycal/main.py index c1dd0f1..150e865 100644 --- a/inkycal/main.py +++ b/inkycal/main.py @@ -130,6 +130,8 @@ class Inkycal: self.cache = JSONCache(CACHE_NAME) self.cache_data = self.cache.read() + self.counter = 0 if "counter" not in self.cache_data else int(self.cache_data["counter"]) + # Give an OK message print('loaded inkycal') @@ -259,8 +261,6 @@ class Inkycal: # Function to flip images upside down upside_down = lambda image: image.rotate(180, expand=True) - # Count the number of times without any errors - counter = 0 print(f'Inkycal version: v{self._release}') print(f'Selected E-paper display: {self.settings["model"]}') @@ -287,9 +287,9 @@ class Inkycal: if errors: logger.error("Error/s in modules:", *errors) - counter = 0 + self.counter = 0 else: - counter += 1 + self.counter += 1 logger.info("successful") del errors @@ -332,9 +332,13 @@ class Inkycal: (f"{self.image_folder}/canvas.png.hash", im_black),]): display.render(im_black) - print(f'\nNo errors since {counter} display updates \n' + print(f'\nNo errors since {self.counter} display updates \n' f'program started {runtime.humanize()}') + # store the cache data + self.cache.write(self.cache_data) + + # Exit the loop if run_once is True if run_once: break # Exit the loop after one full cycle if run_once is True diff --git a/inkycal/modules/inkycal_stocks.py b/inkycal/modules/inkycal_stocks.py index cf58a41..47a2b55 100755 --- a/inkycal/modules/inkycal_stocks.py +++ b/inkycal/modules/inkycal_stocks.py @@ -142,7 +142,7 @@ class Stocks(inkycal_module): logger.warning(f"Failed to get '{stockName}' ticker price hint! Using " "default precision of 2 instead.") - stockHistory = yfTicker.history("30d") + stockHistory = yfTicker.history("1mo") stockHistoryLen = len(stockHistory) logger.info(f'fetched {stockHistoryLen} datapoints ...') previousQuote = (stockHistory.tail(2)['Close'].iloc[0]) diff --git a/requirements.txt b/requirements.txt index 3884b42..4554902 100644 --- a/requirements.txt +++ b/requirements.txt @@ -51,4 +51,4 @@ virtualenv==20.25.0 webencodings==0.5.1 x-wr-timezone==0.0.6 xkcd==2.4.2 -yfinance==0.2.36 +yfinance==0.2.40