Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix required plugins #891

Merged
merged 3 commits into from
Aug 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions UM/PluginRegistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,23 @@ 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
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))

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

pluginsEnabledOrDisabledChanged = pyqtSignal()
Expand Down
Loading