From 762538d4da427ae98371db8196b1de4fe46bf01b Mon Sep 17 00:00:00 2001 From: Ace Date: Tue, 25 Jun 2024 14:22:38 +0200 Subject: [PATCH] minor logging improvements --- inky_run.py | 3 +++ inkycal/main.py | 2 +- inkycal/modules/inky_image.py | 2 +- inkycal/modules/inkycal_agenda.py | 2 +- inkycal/modules/inkycal_feeds.py | 5 +++-- inkycal/modules/inkycal_image.py | 2 +- inkycal/modules/inkycal_jokes.py | 5 +++-- inkycal/modules/inkycal_slideshow.py | 2 +- inkycal/modules/inkycal_stocks.py | 2 +- inkycal/modules/inkycal_textfile_to_display.py | 2 +- inkycal/modules/inkycal_tindie.py | 3 ++- inkycal/modules/inkycal_todoist.py | 3 ++- inkycal/modules/inkycal_weather.py | 5 +++-- inkycal/modules/inkycal_webshot.py | 3 ++- inkycal/modules/inkycal_xkcd.py | 3 ++- 15 files changed, 27 insertions(+), 17 deletions(-) diff --git a/inky_run.py b/inky_run.py index 9f52494..9f4d5f7 100644 --- a/inky_run.py +++ b/inky_run.py @@ -29,6 +29,9 @@ async def run(): # create an instance of Inkycal # If your settings.json file is not in /boot, use the full path: # inky = Inkycal('path/to/settings.json', render=True) + + # when using experimental PiSugar support: + # inky = Inkycal(render=True, use_pi_sugar=True) inky = Inkycal(render=True) await inky.run() # If there were no issues, you can run Inkycal nonstop diff --git a/inkycal/main.py b/inkycal/main.py index 64eecad..8b4a26f 100644 --- a/inkycal/main.py +++ b/inkycal/main.py @@ -319,7 +319,7 @@ class Inkycal: self.counter = 0 else: self.counter += 1 - logger.info("successful") + logger.info("All images generated successfully!") del errors if self.battery_capacity < 20: diff --git a/inkycal/modules/inky_image.py b/inkycal/modules/inky_image.py index 67f4a14..eaefe28 100755 --- a/inkycal/modules/inky_image.py +++ b/inkycal/modules/inky_image.py @@ -59,7 +59,7 @@ class Inkyimage: logger.error("Invalid Image file provided", exc_info=True) raise Exception("Please check if the path points to an image file.") - logger.info(f"width: {image.width}, height: {image.height}") + logger.debug(f"width: {image.width}, height: {image.height}") image.convert(mode="RGBA") # convert to a more suitable format self.image = image diff --git a/inkycal/modules/inkycal_agenda.py b/inkycal/modules/inkycal_agenda.py index 813a3db..5b27d00 100755 --- a/inkycal/modules/inkycal_agenda.py +++ b/inkycal/modules/inkycal_agenda.py @@ -86,7 +86,7 @@ class Agenda(inkycal_module): im_height = int(self.height - (2 * self.padding_top)) im_size = im_width, im_height - logger.info(f'Image size: {im_size}') + logger.debug(f'Image size: {im_size}') # Create an image for black pixels and one for coloured pixels im_black = Image.new('RGB', size=im_size, color='white') diff --git a/inkycal/modules/inkycal_feeds.py b/inkycal/modules/inkycal_feeds.py index d7bdde3..a51eba6 100644 --- a/inkycal/modules/inkycal_feeds.py +++ b/inkycal/modules/inkycal_feeds.py @@ -75,7 +75,7 @@ class Feeds(inkycal_module): im_width = int(self.width - (2 * self.padding_left)) im_height = int(self.height - (2 * self.padding_top)) im_size = im_width, im_height - logger.info(f'Image size: {im_size}') + logger.debug(f'Image size: {im_size}') # Create an image for black pixels and one for coloured pixels im_black = Image.new('RGB', size=im_size, color='white') @@ -83,8 +83,9 @@ class Feeds(inkycal_module): # Check if internet is available if internet_available(): - logger.info('Connection test passed') + logger.debug('Connection test passed') else: + logger.error("Network not reachable. Please check your connection.") raise NetworkNotReachableError # Set some parameters for formatting feeds diff --git a/inkycal/modules/inkycal_image.py b/inkycal/modules/inkycal_image.py index 5387b9b..bb7558b 100755 --- a/inkycal/modules/inkycal_image.py +++ b/inkycal/modules/inkycal_image.py @@ -71,7 +71,7 @@ class Inkyimage(inkycal_module): # Remove background if present im.remove_alpha() - # if autoflip was enabled, flip the image + # if auto-flip was enabled, flip the image if self.autoflip: im.autoflip(self.orientation) diff --git a/inkycal/modules/inkycal_jokes.py b/inkycal/modules/inkycal_jokes.py index 5f0085e..004037b 100755 --- a/inkycal/modules/inkycal_jokes.py +++ b/inkycal/modules/inkycal_jokes.py @@ -39,7 +39,7 @@ class Jokes(inkycal_module): im_width = int(self.width - (2 * self.padding_left)) im_height = int(self.height - (2 * self.padding_top)) im_size = im_width, im_height - logger.info(f'image size: {im_width} x {im_height} px') + logger.debug(f'image size: {im_width} x {im_height} px') # Create an image for black pixels and one for coloured pixels im_black = Image.new('RGB', size=im_size, color='white') @@ -47,8 +47,9 @@ class Jokes(inkycal_module): # Check if internet is available if internet_available(): - logger.info('Connection test passed') + logger.debug('Connection test passed') else: + logger.error("Network not reachable. Please check your connection.") raise NetworkNotReachableError # Set some parameters for formatting feeds diff --git a/inkycal/modules/inkycal_slideshow.py b/inkycal/modules/inkycal_slideshow.py index 253397d..8ac612e 100755 --- a/inkycal/modules/inkycal_slideshow.py +++ b/inkycal/modules/inkycal_slideshow.py @@ -87,7 +87,7 @@ class Slideshow(inkycal_module): im_height = int(self.height - (2 * self.padding_top)) im_size = im_width, im_height - logger.info(f'Image size: {im_size}') + logger.debug(f'Image size: {im_size}') # rotates list items by 1 index def rotate(list: list): diff --git a/inkycal/modules/inkycal_stocks.py b/inkycal/modules/inkycal_stocks.py index 47a2b55..c82506f 100755 --- a/inkycal/modules/inkycal_stocks.py +++ b/inkycal/modules/inkycal_stocks.py @@ -63,7 +63,7 @@ class Stocks(inkycal_module): im_width = int(self.width - (2 * self.padding_left)) im_height = int(self.height - (2 * self.padding_top)) im_size = im_width, im_height - logger.info(f'image size: {im_width} x {im_height} px') + logger.debug(f'image size: {im_width} x {im_height} px') # Create an image for black pixels and one for coloured pixels (required) im_black = Image.new('RGB', size=im_size, color='white') diff --git a/inkycal/modules/inkycal_textfile_to_display.py b/inkycal/modules/inkycal_textfile_to_display.py index 7dc4987..1f5b76e 100644 --- a/inkycal/modules/inkycal_textfile_to_display.py +++ b/inkycal/modules/inkycal_textfile_to_display.py @@ -45,7 +45,7 @@ class TextToDisplay(inkycal_module): im_width = int(self.width - (2 * self.padding_left)) im_height = int(self.height - (2 * self.padding_top)) im_size = im_width, im_height - logger.info(f'Image size: {im_size}') + logger.debug(f'Image size: {im_size}') # Create an image for black pixels and one for coloured pixels im_black = Image.new('RGB', size=im_size, color='white') diff --git a/inkycal/modules/inkycal_tindie.py b/inkycal/modules/inkycal_tindie.py index 24b51cb..c07efa0 100755 --- a/inkycal/modules/inkycal_tindie.py +++ b/inkycal/modules/inkycal_tindie.py @@ -40,7 +40,7 @@ class Tindie(inkycal_module): im_width = int(self.width - (2 * self.padding_left)) im_height = int(self.height - (2 * self.padding_top)) im_size = im_width, im_height - logger.info(f'image size: {im_width} x {im_height} px') + logger.debug(f'image size: {im_width} x {im_height} px') # Create an image for black pixels and one for coloured pixels im_black = Image.new('RGB', size=im_size, color='white') @@ -50,6 +50,7 @@ class Tindie(inkycal_module): if internet_available(): logger.info('Connection test passed') else: + logger.error("Network not reachable. Please check your connection.") raise NetworkNotReachableError # Set some parameters for formatting feeds diff --git a/inkycal/modules/inkycal_todoist.py b/inkycal/modules/inkycal_todoist.py index 55e725e..3d41619 100644 --- a/inkycal/modules/inkycal_todoist.py +++ b/inkycal/modules/inkycal_todoist.py @@ -70,7 +70,7 @@ class Todoist(inkycal_module): im_width = int(self.width - (2 * self.padding_left)) im_height = int(self.height - (2 * self.padding_top)) im_size = im_width, im_height - logger.info(f'Image size: {im_size}') + logger.debug(f'Image size: {im_size}') # Create an image for black pixels and one for coloured pixels im_black = Image.new('RGB', size=im_size, color='white') @@ -80,6 +80,7 @@ class Todoist(inkycal_module): if internet_available(): logger.info('Connection test passed') else: + logger.error("Network not reachable. Please check your connection.") raise NetworkNotReachableError # Set some parameters for formatting todos diff --git a/inkycal/modules/inkycal_weather.py b/inkycal/modules/inkycal_weather.py index 7aeb845..e6b747b 100644 --- a/inkycal/modules/inkycal_weather.py +++ b/inkycal/modules/inkycal_weather.py @@ -154,7 +154,7 @@ class Weather(inkycal_module): im_width = int(self.width - (2 * self.padding_left)) im_height = int(self.height - (2 * self.padding_top)) im_size = im_width, im_height - logger.info(f'Image size: {im_size}') + logger.debug(f'Image size: {im_size}') # Create an image for black pixels and one for coloured pixels im_black = Image.new('RGB', size=im_size, color='white') @@ -162,8 +162,9 @@ class Weather(inkycal_module): # Check if internet is available if internet_available(): - logger.info('Connection test passed') + logger.debug('Connection test passed') else: + logger.error("Network not reachable. Please check your connection.") raise NetworkNotReachableError def get_moon_phase(): diff --git a/inkycal/modules/inkycal_webshot.py b/inkycal/modules/inkycal_webshot.py index 8d08cc6..f4945f6 100644 --- a/inkycal/modules/inkycal_webshot.py +++ b/inkycal/modules/inkycal_webshot.py @@ -90,7 +90,7 @@ class Webshot(inkycal_module): im_width = int(self.width - (2 * self.padding_left)) im_height = int(self.height - (2 * self.padding_top)) im_size = im_width, im_height - logger.info('image size: {} x {} px'.format(im_width, im_height)) + logger.debug('image size: {} x {} px'.format(im_width, im_height)) # Create an image for black pixels and one for coloured pixels (required) im_black = Image.new('RGB', size=im_size, color='white') @@ -100,6 +100,7 @@ class Webshot(inkycal_module): if internet_available(): logger.info('Connection test passed') else: + logger.error("Network not reachable. Please check your connection.") raise Exception('Network could not be reached :/') logger.info( diff --git a/inkycal/modules/inkycal_xkcd.py b/inkycal/modules/inkycal_xkcd.py index 63f7140..f3325d8 100644 --- a/inkycal/modules/inkycal_xkcd.py +++ b/inkycal/modules/inkycal_xkcd.py @@ -68,7 +68,7 @@ class Xkcd(inkycal_module): im_width = int(self.width - (2 * self.padding_left)) im_height = int(self.height - (2 * self.padding_top)) im_size = im_width, im_height - logger.info('image size: {} x {} px'.format(im_width, im_height)) + logger.debug('image size: {} x {} px'.format(im_width, im_height)) # Create an image for black pixels and one for coloured pixels (required) im_black = Image.new('RGB', size=im_size, color='white') @@ -78,6 +78,7 @@ class Xkcd(inkycal_module): if internet_available(): logger.info('Connection test passed') else: + logger.error("Network not reachable. Please check your connection.") raise Exception('Network could not be reached :/') # Set some parameters for formatting feeds