From 427c55ef63b9ed8822b043011d6098075fe3e853 Mon Sep 17 00:00:00 2001 From: Ace Date: Tue, 25 Jun 2024 13:39:33 +0200 Subject: [PATCH] async and logging improvements, minor code cleanup --- clear_display.py | 12 ----------- inky_run.py | 33 +++++++++++++++++++++++++++---- inkycal/loggers.py | 2 +- inkycal/modules/inkycal_agenda.py | 4 +--- 4 files changed, 31 insertions(+), 20 deletions(-) delete mode 100644 clear_display.py diff --git a/clear_display.py b/clear_display.py deleted file mode 100644 index be726f3..0000000 --- a/clear_display.py +++ /dev/null @@ -1,12 +0,0 @@ -""" -Clears the display of any content. -""" -from inkycal import Inkycal - -print("loading Inkycal and display driver...") -inky = Inkycal(render=True) # Initialise Inkycal -print("clearing display...") -inky.calibrate(cycles=1) # Calibrate the display -print("clear complete...") - -print("finished!") diff --git a/inky_run.py b/inky_run.py index 2fb9718..9f52494 100644 --- a/inky_run.py +++ b/inky_run.py @@ -4,9 +4,34 @@ Assumes that the settings.json file is in the /boot directory. set render=True to render the display, set render=False to only run the modules. """ import asyncio + from inkycal import Inkycal -inky = Inkycal(render=True) # Initialise Inkycal -# If your settings.json file is not in /boot, use the full path: inky = Inkycal('path/to/settings.json', render=True) -inky.run(run_once=True) # test if Inkycal can be run correctly, running this will show a bit of info for each module -asyncio.run(inky.run()) # If there were no issues, you can run Inkycal nonstop + +async def dry_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) + inky = Inkycal(render=False) + await inky.run(run_once=True) # dry-run without rendering anything on the display + + +async def clear_display(): + print("loading Inkycal and display driver...") + inky = Inkycal(render=True) # Initialise Inkycal + print("clearing display...") + inky.calibrate(cycles=1) # Calibrate the display + print("clear complete...") + print("finished!") + + +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) + inky = Inkycal(render=True) + await inky.run() # If there were no issues, you can run Inkycal nonstop + + +if __name__ == "__main__": + asyncio.run(run()) diff --git a/inkycal/loggers.py b/inkycal/loggers.py index 97c1c46..3a59c33 100644 --- a/inkycal/loggers.py +++ b/inkycal/loggers.py @@ -8,7 +8,7 @@ from inkycal.settings import Settings # On the console, set a logger to show only important logs # (level ERROR or higher) stream_handler = logging.StreamHandler() -stream_handler.setLevel(logging.ERROR) +stream_handler.setLevel(logging.INFO) settings = Settings() diff --git a/inkycal/modules/inkycal_agenda.py b/inkycal/modules/inkycal_agenda.py index 5b7f5d0..813a3db 100755 --- a/inkycal/modules/inkycal_agenda.py +++ b/inkycal/modules/inkycal_agenda.py @@ -2,9 +2,7 @@ Inkycal Agenda Module Copyright by aceinnolab """ - -import arrow - +import arrow # noqa from inkycal.custom import * from inkycal.modules.ical_parser import iCalendar from inkycal.modules.template import inkycal_module