summaryrefslogtreecommitdiff
path: root/backend/plugin_wrapper.py
diff options
context:
space:
mode:
authorJonas Dellinger <jonas.dellinger@2trde.com>2022-06-16 18:33:43 +0200
committerJonas Dellinger <jonas.dellinger@2trde.com>2022-06-16 18:33:43 +0200
commit0a12fe6102da33977548ba0c277bd4fe34e262ab (patch)
tree7ff803d0d106db43ce206a6cdfc74c187f0d901a /backend/plugin_wrapper.py
parenta95bf94d878f61869895bb22cbff1b4f524c5dca (diff)
downloaddecky-loader-0a12fe6102da33977548ba0c277bd4fe34e262ab.tar.gz
decky-loader-0a12fe6102da33977548ba0c277bd4fe34e262ab.zip
First draft of backend independent plugins
Diffstat (limited to 'backend/plugin_wrapper.py')
-rw-r--r--backend/plugin_wrapper.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/backend/plugin_wrapper.py b/backend/plugin_wrapper.py
new file mode 100644
index 00000000..d41454df
--- /dev/null
+++ b/backend/plugin_wrapper.py
@@ -0,0 +1,34 @@
+import multiprocessing
+from json import load
+from logging import getLogger
+from os import path
+
+from plugin.plugin import get_plugin_backend
+
+
+class PluginWrapper:
+ def __init__(self, plugin_relative_directory, plugin_path) -> None:
+ self.plugin_directory = path.join(plugin_path, plugin_relative_directory)
+
+ json = load(open(path.join(self.plugin_directory, "plugin.json"), "r"))
+
+ self.legacy = False
+ self.main_view_html = json["main_view_html"] if "main_view_html" in json else ""
+ self.tile_view_html = json["tile_view_html"] if "tile_view_html" in json else ""
+ self.legacy = self.main_view_html or self.tile_view_html
+
+ self.name = json["name"]
+ self.author = json["author"]
+ self.flags = json["flags"]
+ self.logger = getLogger(f"{self.name}")
+
+ self.backend = get_plugin_backend(json.get("backend"), self.plugin_directory, self.flags, self.logger)
+
+ def call_method(self, method_name, args):
+ return self.backend.call_method(method_name, args)
+
+ def start(self):
+ return self.backend.start()
+
+ def __str__(self) -> str:
+ return self.name