async and logging improvements, minor code cleanup
This commit is contained in:
		| @@ -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!") |  | ||||||
							
								
								
									
										33
									
								
								inky_run.py
									
									
									
									
									
								
							
							
						
						
									
										33
									
								
								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. | 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 | ||||||
|  |  | ||||||
| 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) | async def dry_run(): | ||||||
| inky.run(run_once=True)  # test if Inkycal can be run correctly, running this will show a bit of info for each module |     # create an instance of Inkycal | ||||||
| asyncio.run(inky.run())  # If there were no issues, you can run Inkycal nonstop |     # 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()) | ||||||
|   | |||||||
| @@ -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() | ||||||
|  |  | ||||||
|   | |||||||
| @@ -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 | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user