From b807eb2d6de1322fba66e8ba61cadc8df3a7c3c7 Mon Sep 17 00:00:00 2001 From: cp2004 <31997505+cp2004@users.noreply.github.com> Date: Sun, 27 Dec 2020 18:30:14 +0000 Subject: [PATCH] :bug: Fix plugin install errors not being reported to the UI When plugin install went async (4cf2a673c8860304472904cf11d13e2187bc17fd) not all of the responses were caught. This PR changes the rest of the responses to become asynchronous as well. Closes #3849 --- .../plugins/pluginmanager/__init__.py | 50 +++++++++++++------ 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/src/octoprint/plugins/pluginmanager/__init__.py b/src/octoprint/plugins/pluginmanager/__init__.py index 0da508497..c95b7bb20 100644 --- a/src/octoprint/plugins/pluginmanager/__init__.py +++ b/src/octoprint/plugins/pluginmanager/__init__.py @@ -687,11 +687,19 @@ class PluginManagerPlugin( and not self._settings.get_boolean(["ignore_throttled"]) ): # currently throttled, we refuse to run - return make_response( - "System is currently throttled, refusing to install " - "anything due to possible stability issues", - 409, + error_msg = ( + "System is currently throttled, refusing to install anything" + " due to possible stability isssues" ) + self._logger.error(error_msg) + result = { + "result": False, + "source": source, + "source_type": source_type, + "reason": error_msg, + } + self._send_result_notification("install", result) + return result try: # Py3 @@ -761,11 +769,20 @@ class PluginManagerPlugin( "Looks like the plugin was already installed. Forcing a reinstall." ) force = True - except Exception: - self._logger.exception("Could not install plugin from %s" % source) - return make_response( - "Could not install plugin from URL, see the log for more details", 500 - ) + except Exception as e: + self._logger.exception("Could not install plugin from {}".format(source)) + self._logger.exception("Reason: {}".format(repr(e))) + result = { + "result": False, + "source": source, + "source_type": source_type, + "reason": "Could not install plugin from {}, see the log for more details".format( + source + ), + } + self._send_result_notification("install", result) + return result + else: if force: # We don't use --upgrade here because that will also happily update all our dependencies - we'd rather @@ -773,16 +790,21 @@ class PluginManagerPlugin( pip_args += ["--ignore-installed", "--force-reinstall", "--no-deps"] try: returncode, stdout, stderr = self._call_pip(pip_args) - except Exception: + except Exception as e: self._logger.exception( "Could not install plugin from {}".format(source) ) - return make_response( - "Could not install plugin from source {}, see the log for more details".format( + self._logger.exception("Reason: {}".format(repr(e))) + result = { + "result": False, + "source": source, + "source_type": source_type, + "reason": "Could not install plugin from source {}, see the log for more details".format( source ), - 500, - ) + } + self._send_result_notification("install", result) + return result try: result_line = list(