From 1e3ec258b1c3fe57bbd9275768209d27c1765db8 Mon Sep 17 00:00:00 2001
From: jneilliii
Date: Thu, 24 Feb 2022 05:02:00 -0500
Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20SWU:=20Allow=20enqueuing=20updates?=
=?UTF-8?q?=20while=20printing=20(#4364)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* adds an update queue to allow starting updates while printing, #3320, #3589, #3585
* change to 202 status code instead of abort for queued installs
* remove commented code
* fix formatting
* UI improvements
proper list merging, without duplicates
* add countdown timer on print completion prior to update
don't automatically update on print fail
add ability to cancel queued updates
* UI tweaks and fixes
* minor bugfix
* if logic adjustment to prevent sending messages to front end when no updates queued
* add timer abort on print start in case he update is in process
* added wait for timelapse completion to avoid interrupting that process due to resstart at the end of updates.
* ♻️ Get rid of some data duplication
...and a TODO
* API adjustments as requested, removed PNotify hack for singleButtonNotify change (broken)
* added print_cancelled flag to deal with changes related to waiting for timelapse
switched PNotify back from singleButtonNotify and added class hidden to button instead to avoid Pnotify.update issue
* 💄 minify CSS
Implements #3320
Implements #3585
Implements #3589
Implements #4431
Co-authored-by: Gina Häußge
---
.../plugins/softwareupdate/__init__.py | 142 ++++++++-
.../static/clientjs/softwareupdate.js | 32 ++
.../static/css/softwareupdate.css | 2 +-
.../static/js/softwareupdate.js | 285 ++++++++++++++++--
.../static/less/softwareupdate.less | 33 ++
.../templates/softwareupdate_settings.jinja2 | 15 +-
src/octoprint/printer/standard.py | 72 ++---
src/octoprint/server/api/printer.py | 3 +-
8 files changed, 481 insertions(+), 103 deletions(-)
diff --git a/src/octoprint/plugins/softwareupdate/__init__.py b/src/octoprint/plugins/softwareupdate/__init__.py
index 12abe7606..890f862a2 100644
--- a/src/octoprint/plugins/softwareupdate/__init__.py
+++ b/src/octoprint/plugins/softwareupdate/__init__.py
@@ -4,7 +4,6 @@ __author__ = "Gina Häußge "
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
__copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms of the AGPLv3 License"
-
import copy
import hashlib
import logging
@@ -28,7 +27,7 @@ from octoprint.server.util.flask import (
no_firstrun_access,
with_revalidation_checking,
)
-from octoprint.util import dict_merge, get_formatted_size, to_unicode, yaml
+from octoprint.util import RepeatedTimer, dict_merge, get_formatted_size, to_unicode, yaml
from octoprint.util.commandline import CommandlineError
from octoprint.util.pip import create_pip_caller
from octoprint.util.version import (
@@ -61,7 +60,6 @@ class SoftwareUpdatePlugin(
octoprint.plugin.WizardPlugin,
octoprint.plugin.EventHandlerPlugin,
):
-
COMMIT_TRACKING_TYPES = ("github_commit", "bitbucket_commit")
CURRENT_TRACKING_TYPES = COMMIT_TRACKING_TYPES + ("etag", "lastmodified", "jsondata")
RELEASE_TRACKING_TYPES = ("github_release",)
@@ -99,6 +97,9 @@ class SoftwareUpdatePlugin(
self._update_log_path = None
self._update_log_dirty = False
self._update_log_mutex = threading.RLock()
+ self._queued_updates = {"targets": [], "force": True}
+ self._queued_updates_abort_timer = None
+ self._print_cancelled = False
self._environment_supported = True
self._environment_versions = {}
@@ -762,6 +763,8 @@ class SoftwareUpdatePlugin(
data["pip_enable_check"] = "pip" in checks
+ data["queued_updates"] = self._queued_updates.get("targets", [])
+
return data
def get_settings_restricted_paths(self):
@@ -1284,10 +1287,6 @@ class SoftwareUpdatePlugin(
description=message,
)
- if self._printer.is_printing() or self._printer.is_paused():
- # do not update while a print job is running
- flask.abort(409, description="Printer is currently printing or paused")
-
if not self._environment_supported:
flask.abort(
409,
@@ -1316,9 +1315,64 @@ class SoftwareUpdatePlugin(
force = json_data.get("force", "false") in octoprint.settings.valid_boolean_trues
+ if self._printer.is_printing() or self._printer.is_paused():
+ # do not update while a print job is running
+ # store targets to be run later on print done event
+ self._queued_updates["targets"] = list(
+ set(self._queued_updates["targets"] + targets)
+ )
+ self._send_client_message(
+ "queued_updates",
+ {"targets": self._queued_updates["targets"]},
+ )
+
+ return (
+ flask.jsonify({"queued": self._queued_updates.get("targets", False)}),
+ 202,
+ )
+
to_be_checked, checks = self.perform_updates(targets=targets, force=force)
return flask.jsonify({"order": to_be_checked, "checks": checks})
+ @octoprint.plugin.BlueprintPlugin.route("/update/queued", methods=["POST"])
+ @no_firstrun_access
+ @Permissions.PLUGIN_SOFTWAREUPDATE_UPDATE.require(403)
+ def cancel_queued(self):
+ if "application/json" not in flask.request.headers["Content-Type"]:
+ flask.abort(400, description="Expected content-type JSON")
+
+ json_data = flask.request.get_json(silent=True)
+ if json_data is None:
+ flask.abort(400, description="Invalid JSON")
+
+ command = json_data.get("command")
+ if command == "cancel":
+ targets = [x.strip() for x in json_data.get("targets", [])]
+
+ if targets:
+ self._queued_updates["targets"] = [
+ x for x in self._queued_updates["targets"] if x not in targets
+ ]
+ else:
+ self._queued_updates["targets"] = []
+
+ if not self._queued_updates["targets"] and self._queued_updates_abort_timer:
+ self._queued_updates_abort_timer.cancel()
+ self._queued_updates_abort_timer = None
+
+ self._send_client_message(
+ "queued_updates",
+ {"targets": self._queued_updates["targets"]},
+ )
+
+ return (
+ flask.jsonify({"queued": self._queued_updates["targets"]}),
+ 202,
+ )
+
+ else:
+ flask.abort(400, description="Expected a valid command")
+
@octoprint.plugin.BlueprintPlugin.route("/configure", methods=["POST"])
@no_firstrun_access
@Permissions.PLUGIN_SOFTWAREUPDATE_CONFIGURE.require(403)
@@ -1475,7 +1529,33 @@ class SoftwareUpdatePlugin(
def on_event(self, event, payload):
from octoprint.events import Events
- if (
+ if event == Events.PRINT_STARTED:
+ self._queued_updates_timer_stop()
+ self._print_cancelled = False
+ elif (
+ event == Events.PRINT_DONE
+ and self._settings.global_get(["webcam", "timelapse", "type"]) == "off"
+ and len(self._queued_updates.get("targets", [])) > 0
+ ):
+ self._queued_updates_timer_start()
+ elif (
+ event == Events.PRINT_FAILED
+ and len(self._queued_updates.get("targets", [])) > 0
+ ):
+ self._send_client_message(
+ "queued_updates",
+ {"print_failed": True, "targets": self._queued_updates["targets"]},
+ )
+ self._print_cancelled = True
+ elif (
+ event == Events.MOVIE_DONE
+ and self._settings.global_get(["webcam", "timelapse", "type"]) != "off"
+ and len(self._queued_updates.get("targets", [])) > 0
+ and not (self._printer.is_printing() or self._printer.is_paused())
+ and not self._print_cancelled
+ ):
+ self._queued_updates_timer_start()
+ elif (
event != Events.CONNECTIVITY_CHANGED
or not payload
or not payload.get("new", False)
@@ -1824,6 +1904,52 @@ class SoftwareUpdatePlugin(
self._version_cache_dirty = True
return information, update_available, update_possible, online, error
+ def _queued_updates_timer_start(self):
+ if self._queued_updates_abort_timer is not None:
+ return
+
+ self._logger.debug("Starting queued updates timer.")
+
+ self._timeout_value = 60
+ self._queued_updates_abort_timer = RepeatedTimer(
+ 1, self._queued_updates_timer_task
+ )
+ self._queued_updates_abort_timer.start()
+
+ def _queued_updates_timer_stop(self):
+ if self._queued_updates_abort_timer is not None:
+ self._queued_updates_abort_timer.cancel()
+ self._queued_updates_abort_timer = None
+ self._send_client_message(
+ "queued_updates",
+ {
+ "targets": self._queued_updates["targets"],
+ "timeout_value": -1,
+ },
+ )
+
+ def _queued_updates_timer_task(self):
+ if self._timeout_value is None:
+ return
+
+ self._timeout_value -= 1
+ if self._timeout_value <= 0:
+ if self._queued_updates_abort_timer is not None:
+ self._queued_updates_abort_timer.cancel()
+ self._queued_updates_abort_timer = None
+ self.perform_updates(
+ targets=self._queued_updates["targets"],
+ force=self._queued_updates["force"],
+ )
+ self._queued_updates = {"targets": [], "force": True}
+ self._send_client_message(
+ "queued_updates",
+ {
+ "targets": self._queued_updates["targets"],
+ "timeout_value": self._timeout_value,
+ },
+ )
+
def perform_updates(self, force=False, **kwargs):
"""
Performs the updates for the given check_targets. Will update all possible targets by default.
diff --git a/src/octoprint/plugins/softwareupdate/static/clientjs/softwareupdate.js b/src/octoprint/plugins/softwareupdate/static/clientjs/softwareupdate.js
index e4bf77a80..9b782c5c4 100644
--- a/src/octoprint/plugins/softwareupdate/static/clientjs/softwareupdate.js
+++ b/src/octoprint/plugins/softwareupdate/static/clientjs/softwareupdate.js
@@ -13,6 +13,7 @@
this.updateUrl = url + "update";
this.configureUrl = url + "configure";
this.updatelogUrl = url + "updatelog";
+ this.queuedURL = this.updateUrl + "/queued";
};
OctoPrintSoftwareUpdateClient.prototype.checkEntries = function (
@@ -72,6 +73,37 @@
return this.base.postJson(this.updateUrl, data, opts);
};
+ OctoPrintSoftwareUpdateClient.prototype.cancelQueued = function (targets, opts) {
+ if (arguments.length === 1 && _.isObject(arguments[0])) {
+ var params = arguments[0];
+ targets = params.targets;
+ }
+
+ targets = targets || [];
+ if (typeof targets === "string") {
+ targets = [targets];
+ }
+
+ var data = {
+ command: "cancel",
+ targets: targets
+ };
+ return this.base.postJson(this.queuedURL, data, opts);
+ };
+
+ OctoPrintSoftwareUpdateClient.prototype.cancelAllQueued = function (opts) {
+ if (arguments.length === 1 && _.isObject(arguments[0])) {
+ var params = arguments[0];
+ opts = params.opts;
+ }
+
+ var data = {
+ command: "cancel"
+ };
+
+ return this.base.postJson(this.queuedURL, data, opts);
+ };
+
OctoPrintSoftwareUpdateClient.prototype.updateAll = function (force, opts) {
if (arguments.length === 1 && _.isObject(arguments[0])) {
var params = arguments[0];
diff --git a/src/octoprint/plugins/softwareupdate/static/css/softwareupdate.css b/src/octoprint/plugins/softwareupdate/static/css/softwareupdate.css
index 36015f226..01bfc4500 100644
--- a/src/octoprint/plugins/softwareupdate/static/css/softwareupdate.css
+++ b/src/octoprint/plugins/softwareupdate/static/css/softwareupdate.css
@@ -1 +1 @@
-#settings_plugin_softwareupdate_updatelist{display:block;width:auto;overflow-x:hidden;padding-right:2px;margin-bottom:1em}div.swupdate-advanced{margin-bottom:5px}td.settings_plugin_softwareupdate_column_update{width:16px}td.settings_plugin_softwareupdate_column_update a{text-decoration:none;color:#000}td.settings_plugin_softwareupdate_column_information .line{display:block}td.settings_plugin_softwareupdate_column_information .settings_plugin_softwareupdate_release_channel{line-height:20px;height:20px;font-size:9px;margin-bottom:0;vertical-align:baseline}#settings_plugin_softwareupdate_updatelog_list .line{display:block}#settings_plugin_softwareupdate_updatelog_list td.settings_plugin_softwareupdate_column_datetime{width:150px}#settings_plugin_softwareupdate_workingdialog_output{font-size:.8em}#settings_plugin_softwareupdate_workingdialog_output .message{font-weight:bold}#settings_plugin_softwareupdate_workingdialog_output .separator{font-weight:bold;color:#666666}#settings_plugin_softwareupdate_workingdialog_output .stdout{color:#333333}#settings_plugin_softwareupdate_workingdialog_output .stderr{color:#990000}#settings_plugin_softwareupdate_workingdialog_output .call{color:#000099}#settings_plugin_softwareupdate_workingdialog_output .message_error{font-weight:bold;color:#990000}.softwareupdate_notification ul{margin:10px 0 10px 25px}.softwareupdate_notification ul .name{text-overflow:ellipsis;white-space:nowrap;overflow:hidden;display:block}
\ No newline at end of file
+#settings_plugin_softwareupdate_updatelist{display:block;width:auto;overflow-x:hidden;padding-right:2px;margin-bottom:1em}div.swupdate-advanced{margin-bottom:5px}td.settings_plugin_softwareupdate_column_update{width:16px}td.settings_plugin_softwareupdate_column_update a{text-decoration:none;color:#000}td.settings_plugin_softwareupdate_column_information .line{display:block}td.settings_plugin_softwareupdate_column_information .settings_plugin_softwareupdate_release_channel{line-height:20px;height:20px;font-size:9px;margin-bottom:0;vertical-align:baseline}#settings_plugin_softwareupdate_updatelog_list .line{display:block}#settings_plugin_softwareupdate_updatelog_list td.settings_plugin_softwareupdate_column_datetime{width:150px}#settings_plugin_softwareupdate_workingdialog_output{font-size:.8em}#settings_plugin_softwareupdate_workingdialog_output .message{font-weight:bold}#settings_plugin_softwareupdate_workingdialog_output .separator{font-weight:bold;color:#666666}#settings_plugin_softwareupdate_workingdialog_output .stdout{color:#333333}#settings_plugin_softwareupdate_workingdialog_output .stderr{color:#990000}#settings_plugin_softwareupdate_workingdialog_output .call{color:#000099}#settings_plugin_softwareupdate_workingdialog_output .message_error{font-weight:bold;color:#990000}.softwareupdate_notification ul{margin:10px 0 10px 25px}.softwareupdate_notification ul .name{text-overflow:ellipsis;white-space:nowrap;overflow:hidden;display:block}.progress-softwareupdate.progress{position:relative;display:flex;overflow:hidden;height:25px;font-size:12px}.progress-softwareupdate.progress .bar{display:flex;justify-content:center;align-items:center;width:100%;color:white;height:25px;font-size:12px}.progress-softwareupdate.progress .progress-text{position:absolute;display:flex;justify-content:center;align-items:center;left:0;right:0;top:0;bottom:0;background:white;transition:clip-path 1s linear;height:25px;font-size:12px}
\ No newline at end of file
diff --git a/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js b/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js
index f9a162547..3505bc5a6 100644
--- a/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js
+++ b/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js
@@ -14,10 +14,12 @@ $(function () {
self.popup = undefined;
self.updateInProgress = false;
+ self.cancelInProgress = false;
self.waitingForRestart = false;
self.restartTimeout = undefined;
self.currentlyBeingUpdated = [];
+ self.queuedUpdates = ko.observableArray([]);
self.working = ko.observable(false);
self.workingTitle = ko.observable();
@@ -76,7 +78,6 @@ $(function () {
!self.updateInProgress &&
self.environmentSupported() &&
self.storageSufficient() &&
- !self.printerState.isPrinting() &&
!self.throttled()
);
});
@@ -91,6 +92,14 @@ $(function () {
);
});
+ self.enableCancelQueued = ko.pureComputed(function () {
+ return self.queuedUpdates().length > 0;
+ });
+
+ self.updateQueued = function (item) {
+ return self.queuedUpdates().indexOf(item.key) > -1;
+ };
+
self.enable_configSave = ko.pureComputed(function () {
return (
self.config_checkType() === "github_release" ||
@@ -155,6 +164,16 @@ $(function () {
});
});
+ self.availableAndQueued = ko.pureComputed(function () {
+ return _.filter(self.versions.items(), function (info) {
+ return (
+ info.updateAvailable &&
+ info.updatePossible &&
+ self.queuedUpdates.indexOf(info.key) > -1
+ );
+ });
+ });
+
self.throttled = ko.pureComputed(function () {
return (
self.piSupport &&
@@ -252,6 +271,12 @@ $(function () {
});
};
+ self.onBeforeBinding = function () {
+ self.queuedUpdates(
+ self.settings.settings.plugins.softwareupdate.queued_updates()
+ );
+ };
+
self._copyConfig = function () {
var availableCheckTypes = [
{key: "github_release", name: gettext("Release")},
@@ -706,7 +731,6 @@ $(function () {
self.performUpdate = function (force, items) {
if (!self.updateAccess()) return;
- if (self.printerState.isPrinting()) return;
self.updateInProgress = true;
@@ -725,6 +749,29 @@ $(function () {
OctoPrint.plugins.softwareupdate
.update(items, force)
.done(function (data) {
+ if (data.hasOwnProperty("queued")) {
+ self.queuedUpdates(data.queued);
+ var message =
+ "" +
+ gettext(
+ "The install of the following plugin update(s) has been queued for after current print is finished or cancelled."
+ ) +
+ '
' +
+ _.map(self.availableAndQueued(), function (info) {
+ return info.displayName;
+ }).join(" ") +
+ "
";
+ self._showPopup({
+ title: gettext("Updates Queued"),
+ text: message,
+ type: "info",
+ buttons: {
+ sticker: false
+ }
+ });
+ self.updateInProgress = false;
+ return;
+ }
self.currentlyBeingUpdated = data.checks;
self._markWorking(
gettext("Updating..."),
@@ -780,18 +827,6 @@ $(function () {
items = self.availableAndPossibleAndEnabled();
}
- if (self.printerState.isPrinting()) {
- self._showPopup({
- title: gettext("Can't update while printing"),
- text: gettext(
- "A print job is currently in progress. Updating will be prevented until it is done."
- ),
- type: "error"
- });
- self._updateClicked = false;
- return;
- }
-
if (self.throttled()) {
self._showPopup({
title: gettext("Can't update while throttled"),
@@ -836,13 +871,13 @@ $(function () {
"Be sure to read through any linked release notes, especially those for OctoPrint since they might contain important information you need to know before upgrading."
) +
"" +
- "" +
- gettext("This action may disrupt any ongoing print jobs.") +
- "
" +
"" +
+ gettext("Updates will be queued if currently printing,") +
+ " " +
gettext(
- "Depending on your printer's controller and general setup, restarting OctoPrint may cause your printer to be reset."
+ "however this action may disrupt any ongoing print if OctoPrint is not currently controlling it."
) +
+ " " +
"
" +
"" +
gettext("Are you sure you want to proceed?") +
@@ -972,6 +1007,24 @@ $(function () {
}
};
+ self.cancelQueued = function (items) {
+ self.cancelInProgress = true;
+ OctoPrint.plugins.softwareupdate
+ .cancelQueued({
+ targets: _.map(items, function (info) {
+ return info.key;
+ })
+ })
+ .done(function (data) {
+ self.queuedUpdates(data.queued);
+ self.cancelInProgress = false;
+ })
+ .fail(function (response) {
+ console.log(response);
+ self.cancelInProgress = false;
+ });
+ };
+
self.onDataUpdaterPluginMessage = function (plugin, data) {
if (plugin !== "softwareupdate") {
return;
@@ -1170,24 +1223,190 @@ $(function () {
self.performCheck();
break;
}
- }
+ case "queued_updates":
+ {
+ if (!self.updateAccess()) {
+ return;
+ }
+ if (messageData.hasOwnProperty("targets")) {
+ self.queuedUpdates(messageData.targets);
+ var queuedUpdatesPopupOptions = {
+ title: title,
+ text: text,
+ type: "notice",
+ icon: false,
+ hide: false,
+ buttons: {
+ closer: false,
+ sticker: false
+ },
+ history: {
+ history: false
+ }
+ };
- if (options !== undefined) {
- self._showPopup(options);
- }
- };
+ if (
+ messageData.print_failed &&
+ messageData.targets.length > 0
+ ) {
+ queuedUpdatesPopupOptions.title = gettext(
+ "Queued Updates Paused"
+ );
+ queuedUpdatesPopupOptions.text =
+ '
' +
+ _.map(self.availableAndQueued(), function (info) {
+ return info.displayName;
+ }).join(" ") +
+ " ";
+ queuedUpdatesPopupOptions.confirm = {
+ confirm: true,
+ buttons: [
+ {
+ text: gettext("Continue Updates"),
+ addClass: "btn-block btn-primary",
+ promptTrigger: true,
+ click: function (notice, value) {
+ notice.remove();
+ notice
+ .get()
+ .trigger("pnotify.continue", [
+ notice,
+ value
+ ]);
+ }
+ },
+ {
+ text: gettext("Cancel Updates"),
+ addClass: "btn-block btn-danger",
+ promptTrigger: true,
+ click: function (notice, value) {
+ notice.remove();
+ notice
+ .get()
+ .trigger("pnotify.cancel", [
+ notice,
+ value
+ ]);
+ }
+ }
+ ]
+ };
+ } else if (
+ messageData.hasOwnProperty("timeout_value") &&
+ messageData.timeout_value > 0 &&
+ messageData.targets.length > 0
+ ) {
+ var progress_percent = Math.floor(
+ (messageData.timeout_value / 60) * 100
+ );
+ var progress_class =
+ progress_percent < 25
+ ? "progress-danger"
+ : progress_percent > 75
+ ? "progress-success"
+ : "progress-warning";
+ queuedUpdatesPopupOptions.title = gettext(
+ "Starting Queued Updates"
+ );
+ queuedUpdatesPopupOptions.text =
+ '' +
+ _.map(self.availableAndQueued(), function (info) {
+ return info.displayName;
+ }).join(" ") +
+ ' ' +
+ gettext("Updating in ") +
+ " " +
+ messageData.timeout_value +
+ " " +
+ gettext("secs") +
+ '
' +
+ gettext("Updating in ") +
+ " " +
+ messageData.timeout_value +
+ " " +
+ gettext("secs") +
+ "
";
+ queuedUpdatesPopupOptions.confirm = {
+ confirm: true,
+ buttons: [
+ {
+ text: gettext("Cancel Updates"),
+ addClass: "btn-block btn-danger",
+ promptTrigger: true,
+ click: function (notice, value) {
+ notice.remove();
+ notice
+ .get()
+ .trigger("pnotify.cancel", [
+ notice,
+ value
+ ]);
+ }
+ },
+ {
+ text: "",
+ addClass: "hidden"
+ }
+ ]
+ };
+ } else {
+ if (typeof self.queuedUpdatesPopup !== "undefined") {
+ self.queuedUpdatesPopup.remove();
+ self.queuedUpdatesPopup = undefined;
+ }
+ return;
+ }
- self._forcedStdoutPatterns = [
- "You are using pip version .*?, however version .*? is available.",
- "You should consider upgrading via the '.*?' command.",
- "'.*?' does not exist -- can't clean it"
- ];
- self._forcedStdoutLine = new RegExp(self._forcedStdoutPatterns.join("|"));
- self._preprocessLine = function (line) {
- if (line.stream === "stderr" && line.line.match(self._forcedStdoutLine)) {
- line.stream = "stdout";
+ if (typeof self.queuedUpdatesPopup !== "undefined") {
+ self.queuedUpdatesPopup.update(queuedUpdatesPopupOptions);
+ } else {
+ self.queuedUpdatesPopup = new PNotify(
+ queuedUpdatesPopupOptions
+ );
+ self.queuedUpdatesPopup
+ .get()
+ .on("pnotify.cancel", function () {
+ self.queuedUpdatesPopup = undefined;
+ self.cancelQueued();
+ });
+ self.queuedUpdatesPopup
+ .get()
+ .on("pnotify.continue", function () {
+ self.queuedUpdatesPopup = undefined;
+ self.performUpdate(true, self.queuedUpdates());
+ self._updateClicked = false;
+ });
+ }
+ } else {
+ if (typeof self.queuedUpdatesPopup !== "undefined") {
+ self.queuedUpdatesPopup.remove();
+ self.queuedUpdatesPopup = undefined;
+ }
+ }
+ }
+
+ if (options !== undefined) {
+ self._showPopup(options);
+ }
}
- return line;
+ self._forcedStdoutPatterns = [
+ "You are using pip version .*?, however version .*? is available.",
+ "You should consider upgrading via the '.*?' command.",
+ "'.*?' does not exist -- can't clean it"
+ ];
+ self._forcedStdoutLine = new RegExp(self._forcedStdoutPatterns.join("|"));
+ self._preprocessLine = function (line) {
+ if (line.stream === "stderr" && line.line.match(self._forcedStdoutLine)) {
+ line.stream = "stdout";
+ }
+ return line;
+ };
};
}
diff --git a/src/octoprint/plugins/softwareupdate/static/less/softwareupdate.less b/src/octoprint/plugins/softwareupdate/static/less/softwareupdate.less
index 28a6d98bf..2782d15bd 100644
--- a/src/octoprint/plugins/softwareupdate/static/less/softwareupdate.less
+++ b/src/octoprint/plugins/softwareupdate/static/less/softwareupdate.less
@@ -85,3 +85,36 @@ td.settings_plugin_softwareupdate_column_information {
}
}
}
+
+.progress-softwareupdate.progress {
+ position: relative;
+ display: flex;
+ overflow: hidden;
+ height: 25px;
+ font-size: 12px;
+
+ .bar {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ width: 100%;
+ color: white;
+ height: 25px;
+ font-size: 12px;
+ }
+
+ .progress-text {
+ position: absolute;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ left: 0;
+ right: 0;
+ top: 0;
+ bottom: 0;
+ background: white;
+ transition: clip-path 1s linear;
+ height: 25px;
+ font-size: 12px;
+ }
+}
diff --git a/src/octoprint/plugins/softwareupdate/templates/softwareupdate_settings.jinja2 b/src/octoprint/plugins/softwareupdate/templates/softwareupdate_settings.jinja2
index 4427d44aa..2ac61e04b 100644
--- a/src/octoprint/plugins/softwareupdate/templates/softwareupdate_settings.jinja2
+++ b/src/octoprint/plugins/softwareupdate/templates/softwareupdate_settings.jinja2
@@ -63,15 +63,6 @@
Read more on this in the FAQ .
{% endtrans %}
-{% trans %}
-
- OctoPrint is currently printing, updates are disabled.
-
-
- Running updates is not supported while printing in order to not risk any kind of disruption to the print job.
- Please let the print finish before trying to update.
-
-{% endtrans %}
@@ -85,6 +76,9 @@
+
+ {{ _('Cancel Queued') }}
+
{{ _('Update all') }}
@@ -113,7 +107,8 @@
- {{ _('Update') }}
+ {{ _('Update') }}
+ {{ _('Cancel Queued') }}
:
{{ _('Release Channel:') }}
diff --git a/src/octoprint/printer/standard.py b/src/octoprint/printer/standard.py
index be41a65f4..e011044ee 100644
--- a/src/octoprint/printer/standard.py
+++ b/src/octoprint/printer/standard.py
@@ -56,16 +56,6 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
self._fileManager = fileManager
self._printerProfileManager = printerProfileManager
- # state
- # TODO do we really need to hold the temperature here?
- self._temp = None
- self._bedTemp = None
- self._chamberTemp = None
- self._targetTemp = None
- self._targetBedTemp = None
- self._targetChamberTemp = None
- self._custom = None
-
self._temps = DataHistory(
cutoff=settings().getInt(["temperature", "cutoff"]) * 60
)
@@ -843,43 +833,21 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
else:
offsets = {}
- result = {}
- if self._temp is not None:
- for tool in self._temp.keys():
- result["tool%d" % tool] = {
- "actual": self._temp[tool][0],
- "target": self._temp[tool][1],
- "offset": offsets[tool]
- if tool in offsets and offsets[tool] is not None
- else 0,
- }
- if self._bedTemp is not None:
- result["bed"] = {
- "actual": self._bedTemp[0],
- "target": self._bedTemp[1],
- "offset": offsets["bed"]
- if "bed" in offsets and offsets["bed"] is not None
- else 0,
- }
- if self._chamberTemp is not None:
- result["chamber"] = {
- "actual": self._chamberTemp[0],
- "target": self._chamberTemp[1],
- "offset": offsets["chamber"]
- if "chamber" in offsets and offsets["chamber"] is not None
- else 0,
- }
- if self._custom is not None:
- for custom_key in self._custom.keys():
- result[custom_key] = {
- "actual": self._custom[custom_key][0],
- "target": self._custom[custom_key][1],
- }
+ last = self._temps.last
+ if last is None:
+ return {}
- return result
+ return {
+ key: {
+ "actual": value["actual"],
+ "target": value["target"],
+ "offset": offsets[key] if offsets.get(key) is not None else 0,
+ }
+ for key, value in last.items()
+ }
def get_temperature_history(self, *args, **kwargs):
- return self._temps
+ return list(self._temps)
def get_current_connection(self, *args, **kwargs):
if self._comm is None:
@@ -1229,11 +1197,6 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
self._temps.append(data)
- self._temp = tools
- self._bedTemp = bed
- self._chamberTemp = chamber
- self._custom = custom
-
self._stateMonitor.add_temperature(self._dict(**data))
def _validateJob(self, filename, sd):
@@ -2097,3 +2060,14 @@ class DataHistory(InvariantContainer):
return [item for item in data if item["time"] >= now - cutoff]
InvariantContainer.__init__(self, guarantee_invariant=data_invariant)
+ self._last = None
+
+ @property
+ def last(self):
+ return self._last
+
+ def append(self, item):
+ try:
+ return super().append(item)
+ finally:
+ self._last = self._data[-1] if len(self._data) else None
diff --git a/src/octoprint/server/api/printer.py b/src/octoprint/server/api/printer.py
index b892df317..d92f7bb93 100644
--- a/src/octoprint/server/api/printer.py
+++ b/src/octoprint/server/api/printer.py
@@ -463,13 +463,12 @@ def _get_temperature_data(preprocessor):
tempData = printer.get_current_temperatures()
if "history" in request.values and request.values["history"] in valid_boolean_trues:
- tempHistory = printer.get_temperature_history()
+ history = printer.get_temperature_history()
limit = 300
if "limit" in request.values and str(request.values["limit"]).isnumeric():
limit = int(request.values["limit"])
- history = list(tempHistory)
limit = min(limit, len(history))
tempData.update(