From aa9a2335ce6095f40284d85e649434cf3d22c7e9 Mon Sep 17 00:00:00 2001 From: cp2004 <31997505+cp2004@users.noreply.github.com> Date: Sat, 13 Mar 2021 21:36:37 +0000 Subject: [PATCH] :pencil2: Show meaningful message when software update is blocked And log when it is undervoltage. The problem here was twofold: first, a very generic message asking to check the log confused users. Second, there was nothing logged when it said check the logs. So, this changes that so the message is escaped and displayed in the pnotify and when the update is blocked for undervoltage this is logged. This does not add logging for other methods, since it seems unnecessary to me. Closes #4024 --- src/octoprint/plugins/softwareupdate/__init__.py | 8 ++++++-- .../softwareupdate/static/js/softwareupdate.js | 15 +++++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/octoprint/plugins/softwareupdate/__init__.py b/src/octoprint/plugins/softwareupdate/__init__.py index 9203baa7d..45f951961 100644 --- a/src/octoprint/plugins/softwareupdate/__init__.py +++ b/src/octoprint/plugins/softwareupdate/__init__.py @@ -1086,10 +1086,14 @@ class SoftwareUpdatePlugin( and not self._settings.get_boolean(["ignore_throttled"]) ): # currently throttled, we refuse to run + message = ( + "System is currently throttled, refusing to update " + "anything due to possible stability issues" + ) + self._logger.error(message) flask.abort( 409, - description="System is currently throttled, refusing to update " - "anything due to possible stability issues", + description=message, ) if self._printer.is_printing() or self._printer.is_paused(): diff --git a/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js b/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js index b090c2651..56e8b6f75 100644 --- a/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js +++ b/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js @@ -680,13 +680,20 @@ $(function () { gettext("Updating, please wait.") ); }) - .fail(function () { + .fail(function (response) { self.updateInProgress = false; + var message = + "
" + + gettext( + "The update could not be started. Is it already active? Please consult octoprint.log for details." + ) + + "
" + + _.escape(response.responseJSON.error) + + ""; + self._showPopup({ title: gettext("Update not started!"), - text: gettext( - "The update could not be started. Is it already active? Please consult octoprint.log for details." - ), + text: message, type: "error", hide: false, buttons: {