Fix: Properly report if a plugin simply could not be found after installation
Also more resilience towards odd version numbers that get mangled by python's package management (1.2.3a0 => 1.2.3a)
This commit is contained in:
parent
2f5c3570dd
commit
61bd803942
2 changed files with 33 additions and 3 deletions
|
|
@ -241,12 +241,31 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
|||
package_name = plugin.origin.package_name
|
||||
package_version = plugin.origin.package_version
|
||||
versioned_package = "{package_name}-{package_version}".format(**locals())
|
||||
|
||||
if package_name in installed or versioned_package in installed:
|
||||
# exact match, we are done here
|
||||
new_plugin_key = key
|
||||
new_plugin = plugin
|
||||
break
|
||||
|
||||
else:
|
||||
# it might still be a version that got stripped by python's package resources, e.g. 1.4.5a0 => 1.4.5a
|
||||
found = False
|
||||
|
||||
for inst in installed:
|
||||
if inst.startswith(versioned_package):
|
||||
found = True
|
||||
break
|
||||
|
||||
if found:
|
||||
new_plugin_key = key
|
||||
new_plugin = plugin
|
||||
break
|
||||
else:
|
||||
return make_response("Could not find plugin that was installed", 500)
|
||||
self._logger.warn("The plugin was installed successfully, but couldn't be found afterwards to initialize properly during runtime. Please restart OctoPrint.")
|
||||
result = dict(result=True, url=url, needs_restart=True, needs_refresh=True, was_reinstalled=False, plugin="unknown")
|
||||
self._send_result_notification("install", result)
|
||||
return jsonify(result)
|
||||
|
||||
self._plugin_manager.mark_plugin(new_plugin_key, uninstalled=False)
|
||||
self._plugin_manager.reload_plugins()
|
||||
|
|
|
|||
|
|
@ -511,11 +511,22 @@ $(function() {
|
|||
|
||||
var name = "Unknown";
|
||||
if (action == "install") {
|
||||
var unknown = false;
|
||||
|
||||
if (data.hasOwnProperty("plugin")) {
|
||||
name = data.plugin.name;
|
||||
if (data.plugin == "unknown") {
|
||||
unknown = true;
|
||||
} else {
|
||||
name = data.plugin.name;
|
||||
}
|
||||
}
|
||||
|
||||
if (data.was_reinstalled) {
|
||||
if (unknown) {
|
||||
titleSuccess = _.sprintf(gettext("Plugin installed"));
|
||||
textSuccess = gettext("A plugin was installed successfully, however it was impossible to detect which one. Please Restart OctoPrint to make sure everything will be registered properly");
|
||||
textRestart = textSuccess;
|
||||
textReload = textSuccess;
|
||||
} else if (data.was_reinstalled) {
|
||||
titleSuccess = _.sprintf(gettext("Plugin \"%(name)s\" reinstalled"), {name: name});
|
||||
textSuccess = gettext("The plugin was reinstalled successfully");
|
||||
textRestart = gettext("The plugin was reinstalled successfully, however a restart of OctoPrint is needed for that to take effect.");
|
||||
|
|
|
|||
Loading…
Reference in a new issue