diff options
| author | tza <marios8543@gmail.com> | 2022-04-06 12:53:19 +0300 |
|---|---|---|
| committer | tza <marios8543@gmail.com> | 2022-04-06 12:53:19 +0300 |
| commit | a6943dd7a25d0d787308897f6f55d44e89c216cf (patch) | |
| tree | 5cc3023cd71fa97a79fe5f7f8a73cadfef05253b | |
| parent | 85e5554c05a60b701fd69fabe47e74fb83ebfd68 (diff) | |
| download | decky-loader-a6943dd7a25d0d787308897f6f55d44e89c216cf.tar.gz decky-loader-a6943dd7a25d0d787308897f6f55d44e89c216cf.zip | |
enabled logging, fixed loader refresh bug, removed template
| -rw-r--r-- | README.md | 5 | ||||
| -rw-r--r--[-rwxr-xr-x] | dist/install_nightly.sh | 0 | ||||
| -rw-r--r--[-rwxr-xr-x] | dist/install_release.sh | 0 | ||||
| -rw-r--r-- | plugin_loader/injector.py | 4 | ||||
| -rw-r--r-- | plugin_loader/loader.py | 3 | ||||
| -rw-r--r-- | plugin_loader/main.py | 20 | ||||
| -rw-r--r-- | plugin_template.py | 19 |
7 files changed, 20 insertions, 31 deletions
@@ -12,7 +12,10 @@ 7. Done! Reboot back into Gaming mode and enjoy your plugins! ### Install Plugins -- Simply copy the plugin's .py file into `~/homebrew/plugins` +- Simply copy the plugin's folder into `~/homebrew/plugins` + +### Developing plugins +- There is no complete plugin development documentation yet. However a good starting point is the [Plugin Template](https://github.com/SteamDeckHomebrew/Plugin-Template) repository ## Features - Clean injecting and loading of one or more plugins diff --git a/dist/install_nightly.sh b/dist/install_nightly.sh index 26384e03..26384e03 100755..100644 --- a/dist/install_nightly.sh +++ b/dist/install_nightly.sh diff --git a/dist/install_release.sh b/dist/install_release.sh index 449b720d..449b720d 100755..100644 --- a/dist/install_release.sh +++ b/dist/install_release.sh diff --git a/plugin_loader/injector.py b/plugin_loader/injector.py index 771d5c51..e130d830 100644 --- a/plugin_loader/injector.py +++ b/plugin_loader/injector.py @@ -1,7 +1,7 @@ #Injector code from https://github.com/SteamDeckHomebrew/steamdeck-ui-inject. More info on how it works there. from aiohttp import ClientSession -from logging import info +from logging import debug from asyncio import sleep BASE_ADDRESS = "http://localhost:8080" @@ -82,4 +82,4 @@ async def inject_to_tab(tab_name, js): tab = next((i for i in tabs if i.title == tab_name), None) if not tab: raise ValueError("Tab {} not found in running tabs".format(tab_name)) - info(await tab.evaluate_js(js)) + debug(await tab.evaluate_js(js)) diff --git a/plugin_loader/loader.py b/plugin_loader/loader.py index 48776d51..8460c792 100644 --- a/plugin_loader/loader.py +++ b/plugin_loader/loader.py @@ -85,9 +85,10 @@ class Loader: if not hasattr(module.Plugin, "name"): raise KeyError("Plugin {} has not defined a name".format(file)) if module.Plugin.name in self.plugins: - if hasattr(module.Plugin, "hot_reload") and not module.Plugin.hot_reload: + if hasattr(module.Plugin, "hot_reload") and not module.Plugin.hot_reload and refresh: self.logger.info("Plugin {} is already loaded and has requested to not be re-loaded" .format(module.Plugin.name)) + return else: if hasattr(self.plugins[module.Plugin.name], "task"): self.plugins[module.Plugin.name].task.cancel() diff --git a/plugin_loader/main.py b/plugin_loader/main.py index da371310..7e13a2d8 100644 --- a/plugin_loader/main.py +++ b/plugin_loader/main.py @@ -1,7 +1,18 @@ +from logging import basicConfig, INFO, DEBUG +from os import getenv +CONFIG = { + "plugin_path": getenv("PLUGIN_PATH", "/home/deck/homebrew/plugins"), + "server_host": getenv("SERVER_HOST", "127.0.0.1"), + "server_port": int(getenv("SERVER_PORT", "1337")), + "live_reload": getenv("LIVE_RELOAD", "1") == "1", + "log_level": {"CRITICAL": 50, "ERROR": 40, "WARNING":30, "INFO": 20, "DEBUG": 10}[getenv("LOG_LEVEL", "INFO")] +} +basicConfig(level=CONFIG["log_level"], format="[%(module)s][%(levelname)s]: %(message)s") + from aiohttp.web import Application, run_app, static from aiohttp_jinja2 import setup as jinja_setup from jinja2 import FileSystemLoader -from os import getenv, path +from os import path from asyncio import get_event_loop from json import loads, dumps @@ -9,13 +20,6 @@ from loader import Loader from injector import inject_to_tab, get_tabs from utilities import util_methods -CONFIG = { - "plugin_path": getenv("PLUGIN_PATH", "/home/deck/homebrew/plugins"), - "server_host": getenv("SERVER_HOST", "127.0.0.1"), - "server_port": int(getenv("SERVER_PORT", "1337")), - "live_reload": getenv("LIVE_RELOAD", "1") == "1" -} - class PluginManager: def __init__(self) -> None: self.loop = get_event_loop() diff --git a/plugin_template.py b/plugin_template.py deleted file mode 100644 index 43088b14..00000000 --- a/plugin_template.py +++ /dev/null @@ -1,19 +0,0 @@ -class Plugin: - name = "Template Plugin" - - author = "SteamDeckHomebrew" - - main_view_html = "<html><body><h3>Template Plugin</h3></body></html>" - - tile_view_html = "" - - hot_reload = False - - async def __main(self): - pass - - async def method_1(self, **kwargs): - pass - - async def method_2(self, **kwargs): - pass
\ No newline at end of file |
