summaryrefslogtreecommitdiff
path: root/backend/plugin_wrapper.py
diff options
context:
space:
mode:
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