diff --git a/backend/browser.py b/backend/browser.py index f6cae5d3..dbdf2d5f 100644 --- a/backend/browser.py +++ b/backend/browser.py @@ -1,5 +1,7 @@ # Full imports import json +# import pprint +# from pprint import pformat # Partial imports from aiohttp import ClientSession, web @@ -108,11 +110,18 @@ class PluginBrowser: try: logger.info("uninstalling " + name) logger.info(" at dir " + self.find_plugin_folder(name)) - logger.debug("unloading %s" % str(name)) - await tab.evaluate_js(f"DeckyPluginLoader.unloadPlugin('{name}')") + logger.debug("calling frontend unload for %s" % str(name)) + res = await tab.evaluate_js(f"DeckyPluginLoader.unloadPlugin('{name}')") + logger.debug("result of unload from UI: %s", res) + # plugins_snapshot = self.plugins.copy() + # snapshot_string = pformat(plugins_snapshot) + # logger.debug("current plugins: %s", snapshot_string) if self.plugins[name]: + logger.debug("Plugin %s was found", name) self.plugins[name].stop() + logger.debug("Plugin %s was stopped", name) del self.plugins[name] + logger.debug("Plugin %s was removed from the dictionary", name) logger.debug("removing files %s" % str(name)) rmtree(self.find_plugin_folder(name)) except FileNotFoundError: diff --git a/backend/plugin.py b/backend/plugin.py index df0efe16..efaeb322 100644 --- a/backend/plugin.py +++ b/backend/plugin.py @@ -92,9 +92,12 @@ class PluginWrapper: async def _unload(self): try: - self.log.info("Attempting to unload " + self.name + "\n") + self.log.info("Attempting to unload with plugin " + self.name + "'s \"_unload\" function.\n") if hasattr(self.Plugin, "_unload"): await self.Plugin._unload(self.Plugin) + self.log.info("Unloaded " + self.name + "\n") + else: + self.log.info("Could not find \"_unload\" in " + self.name + "'s main.py" + "\n") except: self.log.error("Failed to unload " + self.name + "!\n" + format_exc()) exit(0) @@ -118,6 +121,7 @@ class PluginWrapper: break data = loads(line.decode("utf-8")) if "stop" in data: + self.log.info("Calling Loader unload function.") await self._unload() get_event_loop().stop() while get_event_loop().is_running(): diff --git a/frontend/src/plugin-loader.tsx b/frontend/src/plugin-loader.tsx index b0faefeb..426e8480 100644 --- a/frontend/src/plugin-loader.tsx +++ b/frontend/src/plugin-loader.tsx @@ -189,6 +189,7 @@ class PluginLoader extends Logger { } public unloadPlugin(name: string) { + console.log('Plugin List: ', this.plugins); const plugin = this.plugins.find((plugin) => plugin.name === name || plugin.name === name.replace('$LEGACY_', '')); plugin?.onDismount?.(); this.plugins = this.plugins.filter((p) => p !== plugin);