| 
									
										
										
										
											2022-08-24 18:06:26 -07:00
										 |  |  | import logging | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | logging.basicConfig(filename="/tmp/template.log", | 
					
						
							|  |  |  |                     format='[Template] %(asctime)s %(levelname)s %(message)s', | 
					
						
							|  |  |  |                     filemode='w+', | 
					
						
							|  |  |  |                     force=True) | 
					
						
							|  |  |  | logger=logging.getLogger() | 
					
						
							|  |  |  | logger.setLevel(logging.INFO) # can be changed to logging.DEBUG for debugging issues | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-23 00:42:11 +02:00
										 |  |  | class Plugin: | 
					
						
							|  |  |  |     # A normal method. It can be called from JavaScript using call_plugin_function("method_1", argument1, argument2) | 
					
						
							|  |  |  |     async def add(self, left, right): | 
					
						
							|  |  |  |         return left + right | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Asyncio-compatible long-running code, executed in a task when the plugin is loaded | 
					
						
							|  |  |  |     async def _main(self): | 
					
						
							| 
									
										
										
										
											2022-08-24 18:06:26 -07:00
										 |  |  |         logger.info("Hello World!") | 
					
						
							| 
									
										
										
										
											2022-10-22 18:48:59 -07:00
										 |  |  |      | 
					
						
							|  |  |  |     # Function called first during the unload process, utilize this to handle your plugin being removed | 
					
						
							|  |  |  |     async def _unload(self): | 
					
						
							|  |  |  |         logger.info("Goodbye World!") | 
					
						
							| 
									
										
										
										
											2022-04-23 00:42:11 +02:00
										 |  |  |         pass |