summaryrefslogtreecommitdiff
path: root/plugin_loader/plugin.py
diff options
context:
space:
mode:
authortza <marios8543@gmail.com>2022-04-13 22:47:22 +0300
committertza <marios8543@gmail.com>2022-04-13 22:47:22 +0300
commitf685eeb4207e972d98d5e1f92ec0a74cf38a3f85 (patch)
treeda52161af80af7e8f21015488999d42f9d93b151 /plugin_loader/plugin.py
parent6250fafa6e35277d3f30cb23b11193da18adee6c (diff)
downloaddecky-loader-f685eeb4207e972d98d5e1f92ec0a74cf38a3f85.tar.gz
decky-loader-f685eeb4207e972d98d5e1f92ec0a74cf38a3f85.zip
Added support for passive plugins (that don't implement main.py)
Diffstat (limited to 'plugin_loader/plugin.py')
-rw-r--r--plugin_loader/plugin.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/plugin_loader/plugin.py b/plugin_loader/plugin.py
index cd737c72..04feeb27 100644
--- a/plugin_loader/plugin.py
+++ b/plugin_loader/plugin.py
@@ -22,7 +22,11 @@ class PluginWrapper:
self.tile_view_html = json["tile_view_html"] if "tile_view_html" in json else ""
self.flags = json["flags"]
+ self.passive = not path.isfile(self.file)
+
def _init(self):
+ if self.passive:
+ return
setuid(0 if "root" in self.flags else 1000)
spec = spec_from_file_location("_", self.file)
module = module_from_spec(spec)
@@ -62,6 +66,8 @@ class PluginWrapper:
await sleep(0)
def start(self, loop):
+ if self.passive:
+ return self
executor = ProcessPoolExecutor()
loop.run_in_executor(
executor,
@@ -70,6 +76,8 @@ class PluginWrapper:
return self
def stop(self, loop):
+ if self.passive:
+ return
async def _(self):
await self._open_socket_if_not_exists()
self.writer.write((dumps({"stop": True})+"\n").encode("utf-8"))
@@ -77,6 +85,8 @@ class PluginWrapper:
loop.create_task(_(self))
async def execute_method(self, method_name, kwargs):
+ if self.passive:
+ raise RuntimeError("This plugin is passive (aka does not implement main.py)")
async with self.method_call_lock:
await self._open_socket_if_not_exists()
self.writer.write(