async and logging improvements, minor code cleanup

This commit is contained in:
Ace 2024-06-25 13:39:33 +02:00
parent fdd5591456
commit 427c55ef63
4 changed files with 31 additions and 20 deletions

View File

@ -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!")

View File

@ -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. set render=True to render the display, set render=False to only run the modules.
""" """
import asyncio import asyncio
from inkycal import Inkycal from inkycal import Inkycal
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 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) print("clearing display...")
inky.run(run_once=True) # test if Inkycal can be run correctly, running this will show a bit of info for each module inky.calibrate(cycles=1) # Calibrate the display
asyncio.run(inky.run()) # If there were no issues, you can run Inkycal nonstop 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())

View File

@ -8,7 +8,7 @@ from inkycal.settings import Settings
# On the console, set a logger to show only important logs # On the console, set a logger to show only important logs
# (level ERROR or higher) # (level ERROR or higher)
stream_handler = logging.StreamHandler() stream_handler = logging.StreamHandler()
stream_handler.setLevel(logging.ERROR) stream_handler.setLevel(logging.INFO)
settings = Settings() settings = Settings()

View File

@ -2,9 +2,7 @@
Inkycal Agenda Module Inkycal Agenda Module
Copyright by aceinnolab Copyright by aceinnolab
""" """
import arrow # noqa
import arrow
from inkycal.custom import * from inkycal.custom import *
from inkycal.modules.ical_parser import iCalendar from inkycal.modules.ical_parser import iCalendar
from inkycal.modules.template import inkycal_module from inkycal.modules.template import inkycal_module