From 44a2d9062beb3d5a30b72c905789aaddc07c7c69 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 28 Jul 2023 13:37:40 +0200 Subject: [PATCH 1/3] Simplify the check for required plugins This also makes the logging better as it logs all the plugins that could not be loaded --- UM/PluginRegistry.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/UM/PluginRegistry.py b/UM/PluginRegistry.py index acef0dbe2e..c4b60344cc 100644 --- a/UM/PluginRegistry.py +++ b/UM/PluginRegistry.py @@ -206,11 +206,12 @@ def addPluginLocation(self, location: str) -> None: # Check if all required plugins are loaded: def checkRequiredPlugins(self, required_plugins: List[str]) -> bool: - plugins = self._findInstalledPlugins() - for plugin_id in required_plugins: - if plugin_id not in plugins: - Logger.log("e", "Plugin %s is required, but not added or loaded", plugin_id) - return False + installed_plugins = self._findInstalledPlugins() + required_but_not_installed_plugins = list(set(required_plugins).difference(installed_plugins)) + + if required_but_not_installed_plugins: + Logger.error(f"A number of plugins that are required are not added or loaded: {required_but_not_installed_plugins}") + return False return True pluginsEnabledOrDisabledChanged = pyqtSignal() From 5a26ee970ae0c5b4291fc9305e51fb88348c841c Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 28 Jul 2023 13:53:05 +0200 Subject: [PATCH 2/3] Automatically re-enable plugins that are marked as required --- UM/PluginRegistry.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/UM/PluginRegistry.py b/UM/PluginRegistry.py index c4b60344cc..6d78470c84 100644 --- a/UM/PluginRegistry.py +++ b/UM/PluginRegistry.py @@ -206,6 +206,14 @@ def addPluginLocation(self, location: str) -> None: # Check if all required plugins are loaded: def checkRequiredPlugins(self, required_plugins: List[str]) -> bool: + disabled_plugins_that_should_be_enabled = list(set(required_plugins).intersection(set(self._disabled_plugins))) + for disabled_plugin in disabled_plugins_that_should_be_enabled: + # Yeah, this does mean that this run the plugin won't be there. But this can only happen with a corrupted + # list that was caused by bugs / manual fuckery. Enabling it here will ensure that the data is correct + # in the next run + Logger.info(f"The plugin {disabled_plugin} is required but it was disabled. Automatically re-enabling it") + self.enablePlugin(disabled_plugin) + installed_plugins = self._findInstalledPlugins() required_but_not_installed_plugins = list(set(required_plugins).difference(installed_plugins)) From fef9bb5b1a2218c1dac41601e21662ac5e2c1c54 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 28 Jul 2023 15:11:19 +0200 Subject: [PATCH 3/3] Add message when required plugins could not be loaded --- UM/PluginRegistry.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/UM/PluginRegistry.py b/UM/PluginRegistry.py index 6d78470c84..b768c82674 100644 --- a/UM/PluginRegistry.py +++ b/UM/PluginRegistry.py @@ -219,6 +219,9 @@ def checkRequiredPlugins(self, required_plugins: List[str]) -> bool: if required_but_not_installed_plugins: Logger.error(f"A number of plugins that are required are not added or loaded: {required_but_not_installed_plugins}") + message_text = i18n_catalog.i18nc("@error:Required plugins not found", + "A number of plugins are required, but could not be loaded: {plugins}").format(plugins = "\n- ".join(required_but_not_installed_plugins)) + Message(text=message_text, message_type=Message.MessageType.ERROR).show() return False return True