mirror of
https://github.com/SteamDeckHomebrew/decky-plugin-template.git
synced 2025-10-28 22:12:26 -05:00
* add pipinstall script and append py_modules to PYTHONPATH allows dependent python modules to be installed * separate build_frontend and pip_install * use prepare script for installing python modules * use pip3 instead of pip * always create requirements.txt, even if empty
27 lines
995 B
Python
27 lines
995 B
Python
import os
|
|
import sys
|
|
# append py_modules to PYTHONPATH
|
|
sys.path.append(os.path.dirname(os.path.realpath(__file__))+"/py_modules")
|
|
|
|
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
|
|
|
|
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):
|
|
logger.info("Hello World!")
|
|
|
|
# Function called first during the unload process, utilize this to handle your plugin being removed
|
|
async def _unload(self):
|
|
logger.info("Goodbye World!")
|
|
pass
|