From 3de5bca48b1b4b19c356a545efe99f84bead2bd5 Mon Sep 17 00:00:00 2001 From: sylvled <39048447+sylvled@users.noreply.github.com> Date: Mon, 7 May 2018 10:28:14 +0200 Subject: [PATCH 01/34] Update config_yaml.rst gcodeAnalysis and gcodeViewer were without section name. Added them. --- docs/configuration/config_yaml.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/configuration/config_yaml.rst b/docs/configuration/config_yaml.rst index 790702fd1..de5c420f2 100644 --- a/docs/configuration/config_yaml.rst +++ b/docs/configuration/config_yaml.rst @@ -616,6 +616,7 @@ Settings pertaining to the server side GCODE analysis implementation. .. code-block:: yaml +gcodeAnalysis: # Maximum number of extruders to support/to sanity check for maxExtruders: 10 @@ -635,6 +636,7 @@ Settings pertaining to the built in GCODE Viewer. .. code-block:: yaml + gcodeViewer: # Whether to enable the GCODE viewer in the UI enabled: true From 4cb103e042966af0a2138a1bd3c5550277bb9eba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 8 Jun 2018 11:03:44 +0200 Subject: [PATCH 02/34] Fix cancel_preparation call in case of failure It should be _failed if the timer runs out, not _done. Only difference is a log entry though, so not that big of a deal. --- src/octoprint/util/comm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index c1309e1de..ffc3efbda 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -1177,7 +1177,7 @@ class MachineCom(object): if self._cancel_position_timer is not None: self._cancel_position_timer.cancel() self._cancel_position_timer = ResettableTimer(self._timeout_intervals.get("positionLogWait", 10.0), - self._cancel_preparation_done) + self._cancel_preparation_failed) self._cancel_position_timer.daemon = True self._cancel_position_timer.start() self.sendCommand("M114", tags=tags | {"trigger:comm.cancel", From 13e5cf45ec949dc0e15d4f61c0e5284349b1eb85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 23 Mar 2018 14:52:38 +0100 Subject: [PATCH 03/34] Fix reset handling while printing Could get stuck in cancelling due to resend issues. Should fix #2509 --- .../plugins/virtual_printer/virtual.py | 105 +++++++------- src/octoprint/static/js/app/dataupdater.js | 31 ++++- src/octoprint/util/comm.py | 131 +++++++++++++++--- 3 files changed, 190 insertions(+), 77 deletions(-) diff --git a/src/octoprint/plugins/virtual_printer/virtual.py b/src/octoprint/plugins/virtual_printer/virtual.py index 8895a5625..7531df71e 100644 --- a/src/octoprint/plugins/virtual_printer/virtual.py +++ b/src/octoprint/plugins/virtual_printer/virtual.py @@ -168,72 +168,73 @@ class VirtualPrinter(object): .format(read_timeout=self._read_timeout, write_timeout=self._write_timeout, options=settings().get(["devel", "virtualPrinter"])) def _reset(self): - self._clearQueue(self.incoming) - self._clearQueue(self.outgoing) - self._clearQueue(self.buffered) + with self._incoming_lock: + self._relative = True + self._lastX = 0.0 + self._lastY = 0.0 + self._lastZ = 0.0 + self._lastE = [0.0] * self.extruderCount + self._lastF = 200 - self._relative = True - self._lastX = 0.0 - self._lastY = 0.0 - self._lastZ = 0.0 - self._lastE = [0.0] * self.extruderCount - self._lastF = 200 + self._unitModifier = 1 + self._feedrate_multiplier = 100 + self._flowrate_multiplier = 100 - self._unitModifier = 1 - self._feedrate_multiplier = 100 - self._flowrate_multiplier = 100 - - self._sdCardReady = True - self._sdPrinting = False - if self._sdPrinter: + self._sdCardReady = True self._sdPrinting = False - self._sdPrintingSemaphore.set() - self._sdPrinter = None - self._selectedSdFile = None - self._selectedSdFileSize = None - self._selectedSdFilePos = None + if self._sdPrinter: + self._sdPrinting = False + self._sdPrintingSemaphore.set() + self._sdPrinter = None + self._selectedSdFile = None + self._selectedSdFileSize = None + self._selectedSdFilePos = None - if self._writingToSdHandle: - try: - self._writingToSdHandle.close() - except: - pass - self._writingToSd = False - self._writingToSdHandle = None - self._newSdFilePos = None + if self._writingToSdHandle: + try: + self._writingToSdHandle.close() + except: + pass + self._writingToSd = False + self._writingToSdHandle = None + self._newSdFilePos = None - self._heatingUp = False + self._heatingUp = False - self.currentLine = 0 - self.lastN = 0 + self.currentLine = 0 + self.lastN = 0 - self._debug_awol = False - self._debug_sleep = None - self._sleepAfterNext.clear() - self._sleepAfter.clear() + self._debug_awol = False + self._debug_sleep = None + self._sleepAfterNext.clear() + self._sleepAfter.clear() - self._dont_answer = False + self._dont_answer = False - self._debug_drop_connection = False + self._debug_drop_connection = False - self._killed = False + self._killed = False - self._triggerResendAt100 = True - self._triggerResendWithTimeoutAt105 = True - self._triggerResendWithMissingLinenoAt110 = True - self._triggerResendWithChecksumMismatchAt115 = True + self._triggerResendAt100 = True + self._triggerResendWithTimeoutAt105 = True + self._triggerResendWithMissingLinenoAt110 = True + self._triggerResendWithChecksumMismatchAt115 = True - if self._temperature_reporter is not None: - self._temperature_reporter.cancel() - self._temperature_reporter = None + if self._temperature_reporter is not None: + self._temperature_reporter.cancel() + self._temperature_reporter = None - if self._sdstatus_reporter is not None: - self._sdstatus_reporter.cancel() - self._sdstatus_reporter = None + if self._sdstatus_reporter is not None: + self._sdstatus_reporter.cancel() + self._sdstatus_reporter = None - if settings().getBoolean(["devel", "virtualPrinter", "simulateReset"]): - for item in settings().get(["devel", "virtualPrinter", "resetLines"]): - self._send(item + "\n") + self._clearQueue(self.incoming) + self._clearQueue(self.outgoing) + self._clearQueue(self.buffered) + + if settings().getBoolean(["devel", "virtualPrinter", "simulateReset"]): + for item in settings().get(["devel", "virtualPrinter", "resetLines"]): + self._send(item + "\n") @property def timeout(self): diff --git a/src/octoprint/static/js/app/dataupdater.js b/src/octoprint/static/js/app/dataupdater.js index 54074ac8f..e33367740 100644 --- a/src/octoprint/static/js/app/dataupdater.js +++ b/src/octoprint/static/js/app/dataupdater.js @@ -218,6 +218,9 @@ function DataUpdater(allViewModels, connectCallback, disconnectCallback) { }); }; + self._printerErrorCancelNotification = undefined; + self._printerErrorDisconnectNotification = undefined; + self._printerResetNotification = undefined; self._onEvent = function(event) { self._ifInitialized(function() { var type = event.data["type"]; @@ -226,7 +229,10 @@ function DataUpdater(allViewModels, connectCallback, disconnectCallback) { log.debug("Got event " + type + " with payload: " + JSON.stringify(payload)); if (type === "PrintCancelling" && payload.firmwareError) { - new PNotify({ + if (self._printerErrorCancelNotification !== undefined) { + self._printerErrorCancelNotification.remove(); + } + self._printerErrorCancelNotification = new PNotify({ title: gettext("Error reported by printer"), text: _.sprintf(gettext("Your printer's firmware reported an error. Due to that the ongoing print job will be cancelled. Reported error: %(firmwareError)s"), payload), type: "error", @@ -271,7 +277,10 @@ function DataUpdater(allViewModels, connectCallback, disconnectCallback) { } if (title && text) { - new PNotify({ + if (self._printerErrorDisconnectNotification !== undefined) { + self._printerErrorDisconnectNotification.remove(); + } + self._printerErrorDisconnectNotification = new PNotify({ title: title, text: text, type: "error", @@ -279,9 +288,23 @@ function DataUpdater(allViewModels, connectCallback, disconnectCallback) { }); } } else if (type === "PrinterReset") { - new PNotify({ + var severity = undefined, + text = undefined; + if (payload.idle) { + text = gettext("It looks like your printer reset while a connection was active. If this was intentional you may safely ignore this message. Otherwise you should investigate why your printer reset itself, since this will interrupt prints and also file transfers to your printer's SD."); + severity = "alert"; + } else { + text = gettext("It looks like your printer reset while a connection was active. Due to this the ongoing job was aborted. If this was intentional you may safely ignore this message. Otherwise you should investigate why your printer reset itself, since this will interrupt prints and also file transfers to your printer's SD."); + severity = "error"; + } + + if (self._printerResetNotification !== undefined) { + self._printerResetNotification.remove(); + } + self._printerResetNotification = new PNotify({ title: gettext("Printer reset detected"), - text: gettext("It looks like your printer reset while a connection was active. If this was intentional you may safely ignore this message. Otherwise you should investigate why your printer reset itself, since this will interrupt prints and also file transfers to your printer's SD."), + text: text, + type: severity, hide: false }); } diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index ffc3efbda..7ca2027dd 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -382,7 +382,7 @@ class MachineCom(object): self._baudrateDetectRetry = 0 self._temperatureTargetSetThreshold = 25 self._tempOffsets = dict() - self._command_queue = TypedQueue() + self._command_queue = CommandQueue() self._currentZ = None self._currentF = None self._heatupWaitStartTime = None @@ -1622,7 +1622,7 @@ class MachineCom(object): # process resends elif lower_line.startswith("resend") or lower_line.startswith("rs"): - self._handleResendRequest(line) + self._handle_resend_request(line) handled = True # process timeouts @@ -2002,23 +2002,27 @@ class MachineCom(object): self.STATE_PAUSED, self.STATE_TRANSFERING_FILE): if line == "start": # exact match, to be on the safe side - if self._state in (self.STATE_OPERATIONAL,): - message = "Printer sent 'start' while already operational. External reset? " \ - "Resetting line numbers to be on the safe side" - self._log(message) - self._logger.warn(message) - self._onExternalReset() + with self.job_put_on_hold(): + idle = self._state in (self.STATE_OPERATIONAL,) + if idle: + message = "Printer sent 'start' while already operational. External reset? " \ + "Resetting line numbers to be on the safe side" + self._log(message) + self._logger.warn(message) - else: - verb = "streaming to SD" if self.isStreaming() else "printing" - message = "Printer sent 'start' while {}. External reset? " \ - "Aborting job since printer lost state.".format(verb) - self._log(message) - self._logger.warn(message) - self.cancelPrint(disable_log_position=True) - self._onExternalReset() + self._on_external_reset() - eventManager().fire(Events.PRINTER_RESET) + else: + verb = "streaming to SD" if self.isStreaming() else "printing" + message = "Printer sent 'start' while {}. External reset? " \ + "Aborting job since printer lost state.".format(verb) + self._log(message) + self._logger.warn(message) + + self._on_external_reset() + self.cancelPrint(disable_log_position=True) + + eventManager().fire(Events.PRINTER_RESET, payload=dict(idle=idle)) except: self._logger.exception("Something crashed inside the serial connection loop, please report this in OctoPrint's bug tracker:") @@ -2291,7 +2295,19 @@ class MachineCom(object): eventManager().fire(Events.CONNECTED, payload) self.sendGcodeScript("afterPrinterConnected", replacements=dict(event=payload)) - def _onExternalReset(self): + def _on_external_reset(self): + # hold queue processing, clear queues and acknowledgements, reset line number and last lines + with self._send_queue.blocked(): + self._clear_to_send.clear(completely=True) + with self._command_queue.blocked(): + self._command_queue.clear() + self._send_queue.clear() + + with self._line_mutex: + self._currentLine = 0 + self._lastLines.clear() + + self.sayHello(tags={"trigger:comm.on_external_reset"}) self.resetLineNumbers(tags={"trigger:comm.on_external_reset"}) if self._temperature_autoreporting: @@ -2620,13 +2636,19 @@ class MachineCom(object): self._logger.debug("Command \"{}\" from file not enqueued, doing another iteration".format(line)) - def _handleResendRequest(self, line): + def _handle_resend_request(self, line): try: lineToResend = parse_resend_line(line) if lineToResend is None: return False - if self._resendDelta is None and lineToResend == self._currentLine: + if self._resendDelta is None and lineToResend == self._currentLine == 1: + # We probably just handled a resend and this request originates from lines sent before that + self._logger.info("Got a resend request for line 1 which is also our current line. It looks " + "like we just handled a reset and this is a left over of this") + return False + + elif self._resendDelta is None and lineToResend == self._currentLine: # We don't expect to have an active resend request and the printer is requesting a resend of # a line we haven't yet sent. # @@ -2647,7 +2669,7 @@ class MachineCom(object): if lastCommError is not None \ and ("line number" in lastCommError.lower() or "expected line" in lastCommError.lower()) \ and lineToResend == self._lastResendNumber \ - and self._resendDelta is not None and self._currentResendCount < self._resendDelta: + and self._resendDelta is not None and self._currentResendCount < resendDelta: self._logger.info("Ignoring resend request for line %d, that still originates from lines we sent " "before we got the first resend request" % lineToResend) self._currentResendCount += 1 @@ -3782,12 +3804,52 @@ class SpecialStreamingGcodeFileInformation(StreamingGcodeFileInformation): return None return line +class CommandQueue(TypedQueue): + def __init__(self, *args, **kwargs): + TypedQueue.__init__(self, *args, **kwargs) + self._unblocked = threading.Event() + self._unblocked.set() + + def block(self): + self._unblocked.clear() + + def unblock(self): + self._unblocked.set() + + @contextlib.contextmanager + def blocked(self): + self.block() + try: + yield + finally: + self.unblock() + + def get(self, *args, **kwargs): + self._unblocked.wait() + return TypedQueue.get(self, *args, **kwargs) + + def put(self, *args, **kwargs): + self._unblocked.wait() + return TypedQueue.put(self, *args, **kwargs) + + def clear(self): + cleared = [] + while True: + try: + cleared.append(TypedQueue.get(self, False)) + TypedQueue.task_done(self) + except queue.Empty: + break + return cleared class SendQueue(PrependableQueue): def __init__(self, maxsize=0): PrependableQueue.__init__(self, maxsize=maxsize) + self._unblocked = threading.Event() + self._unblocked.set() + self._resend_queue = PrependableQueue() self._send_queue = PrependableQueue() self._lookup = set() @@ -3803,16 +3865,43 @@ class SendQueue(PrependableQueue): with self.mutex: self._resend_active = resend_active + def block(self): + self._unblocked.clear() + + def unblock(self): + self._unblocked.set() + + @contextlib.contextmanager + def blocked(self): + self.block() + try: + yield + finally: + self.unblock() + def prepend(self, item, item_type=None, target=None, block=True, timeout=None): + self._unblocked.wait() PrependableQueue.prepend(self, (item, item_type, target), block=block, timeout=timeout) def put(self, item, item_type=None, target=None, block=True, timeout=None): + self._unblocked.wait() PrependableQueue.put(self, (item, item_type, target), block=block, timeout=timeout) def get(self, block=True, timeout=None): + self._unblocked.wait() item, _, _ = PrependableQueue.get(self, block=block, timeout=timeout) return item + def clear(self): + cleared = [] + while True: + try: + cleared.append(PrependableQueue.get(self, False)) + PrependableQueue.task_done(self) + except queue.Empty: + break + return cleared + def _put(self, item): _, item_type, target = item if item_type is not None: From 534f3aa2d4f2655eac1ecc31458925fa88b3b5e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Sat, 9 Jun 2018 10:15:56 +0200 Subject: [PATCH 04/34] Fix for potential division by zero on SD upload Closes #2675 --- src/octoprint/util/comm.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index 7ca2027dd..341d85832 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -3781,11 +3781,13 @@ class StreamingGcodeFileInformation(PrintingGcodeFileInformation): def _report_stats(self): duration = time.time() - self._start_time - stats = dict(lines=self._read_lines, - rate=float(self._read_lines) / duration, - time_per_line=duration * 1000.0 / float(self._read_lines), - duration=duration) - self._logger.info("Finished in {duration:.3f} s. Approx. transfer rate of {rate:.3f} lines/s or {time_per_line:.3f} ms per line".format(**stats)) + read_lines = self._read_lines + if duration > 0 and read_lines > 0: + stats = dict(lines=read_lines, + rate=float(read_lines) / duration, + time_per_line=duration * 1000.0 / float(read_lines), + duration=duration) + self._logger.info("Finished in {duration:.3f} s. Approx. transfer rate of {rate:.3f} lines/s or {time_per_line:.3f} ms per line".format(**stats)) class SpecialStreamingGcodeFileInformation(StreamingGcodeFileInformation): From 6e441492844eb771b3f222278359feb594001082 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Sat, 9 Jun 2018 11:58:53 +0200 Subject: [PATCH 05/34] Treat scripts triggered by job as part of the job Including blocking their sending via job_on_hold. Closes #2583 --- src/octoprint/printer/standard.py | 8 +++- src/octoprint/util/comm.py | 78 ++++++++++++++++++++----------- 2 files changed, 58 insertions(+), 28 deletions(-) diff --git a/src/octoprint/printer/standard.py b/src/octoprint/printer/standard.py index 3a043d8db..7de61daeb 100644 --- a/src/octoprint/printer/standard.py +++ b/src/octoprint/printer/standard.py @@ -285,7 +285,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): for command in commands: self._comm.sendCommand(command, tags=kwargs.get("tags", set()) | {"trigger:printer.commands"}) - def script(self, name, context=None, must_be_set=True, *args, **kwargs): + def script(self, name, context=None, must_be_set=True, part_of_job=False, *args, **kwargs): if self._comm is None: return @@ -293,6 +293,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): raise ValueError("name must be set") result = self._comm.sendGcodeScript(name, + part_of_job=part_of_job, replacements=context, tags=kwargs.get("tags", set()) | {"trigger:printer.script"}) if not result and must_be_set: @@ -1040,6 +1041,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): if not suppress_script: self.script("beforePrintStarted", context=dict(event=payload), + part_of_job=True, must_be_set=False) def on_comm_print_job_done(self, suppress_script=False): @@ -1058,6 +1060,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): if not suppress_script: self.script("afterPrintDone", context=dict(event=payload), + part_of_job=True, must_be_set=False) def log_print(): @@ -1101,6 +1104,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): if not suppress_script: self.script("afterPrintCancelled", context=dict(event=payload), + part_of_job=True, must_be_set=False) def finalize(): @@ -1123,6 +1127,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): if not suppress_script: self.script("afterPrintPaused", context=dict(event=payload), + part_of_job=True, must_be_set=False) def on_comm_print_job_resumed(self, suppress_script=False): @@ -1132,6 +1137,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): if not suppress_script: self.script("beforePrintResumed", context=dict(event=payload), + part_of_job=True, must_be_set=False) def on_comm_file_transfer_started(self, filename, filesize, user=None): diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index 341d85832..64032f1d0 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -483,6 +483,8 @@ class MachineCom(object): self._temperature_timer = None self._sd_status_timer = None + self._script_queue = ScriptQueue() + # hooks self._pluginManager = octoprint.plugin.plugin_manager() @@ -968,13 +970,17 @@ class MachineCom(object): scriptLines)) - def sendGcodeScript(self, scriptName, replacements=None, tags=None): + def sendGcodeScript(self, scriptName, replacements=None, tags=None, part_of_job=False): if tags is None: tags = set() scriptLines = self._getGcodeScript(scriptName, replacements=replacements) + tags_to_use = tags | {"trigger:comm.send_gcode_script", "source:script", "script:{}".format(scriptName)} for line in scriptLines: - self.sendCommand(line, tags=tags | {"trigger:comm.send_gcode_script", "source:script", "script:{}".format(scriptName)}) + if part_of_job: + self._script_queue.put((line, tags_to_use)) + else: + self.sendCommand(line, tags=tags_to_use) return "\n".join(scriptLines) def startPrint(self, pos=None, tags=None, external_sd=False): @@ -1026,7 +1032,7 @@ class MachineCom(object): if pos is not None and isinstance(pos, int) and pos > 0: self._currentFile.seek(pos) - line, pos, lineno = self._getNext() + line, pos, lineno = self._get_next_from_job() if line is not None: self.sendCommand(line, tags=tags | {"trigger:comm.start_print", "source:file", @@ -1034,7 +1040,7 @@ class MachineCom(object): "fileline:{}".format(lineno)}) # now make sure we actually do something, up until now we only filled up the queue - self._sendFromQueue() + self._send_from_command_queue() except: self._logger.exception("Error while trying to start printing") self._trigger_error(get_exception_string(), "start_print") @@ -1261,7 +1267,7 @@ class MachineCom(object): self.sendCommand("M24", tags=tags | {"trigger:comm.set_pause","trigger:resume"}) self.sendCommand("M27", tags=tags | {"trigger:comm.set_pause", "trigger:resume"}) else: - line, pos, lineno = self._getNext() + line, pos, lineno = self._get_next_from_job() if line is not None: if not tags: tags = set() @@ -1273,7 +1279,7 @@ class MachineCom(object): self.sendCommand(line, tags=tags_to_use) # now make sure we actually do something, up until now we only filled up the queue - self._sendFromQueue() + self._send_from_command_queue() elif pause and self.isPrinting(): if not self._pauseWaitStartTime: @@ -2174,26 +2180,29 @@ class MachineCom(object): def _continue_sending(self): while self._active: + job_active = self._state == self.STATE_PRINTING and not (self._currentFile is None or self._currentFile.done or self.isSdPrinting()) - if self._state == self.STATE_PRINTING and not (self._currentFile is None or self._currentFile.done or self.isSdPrinting()): - # we are printing, we really want to send either something from the command - # queue or the next line from our file, so we only return here if we actually DO - # send something - if self._sendFromQueue(): - # we found something in the queue to send - return True + if self._send_from_command_queue(): + # we found something in the command queue to send + return True - elif self.job_on_hold: - return False + elif self.job_on_hold: + # job is on hold, that means we must not send from either script queue or file + return False - elif self._sendNext(): - # we sent the next line from the file - return True + elif self._send_from_script_queue(): + # we found something in the script queue to send + return True - self._logger.debug("No command sent on ok while printing, doing another iteration") - else: - # just send stuff from the command queue and be done with it - return self._sendFromQueue() + elif job_active and self._send_from_job(): + # we sent the next line from the file + return True + + elif not job_active: + # nothing sent but also no job active, so we can just return false + return False + + self._logger.debug("No command sent on ok while printing, doing another iteration") def _process_registered_message(self, line, feedback_matcher, feedback_controls, feedback_errors): feedback_match = feedback_matcher.search(line) @@ -2341,7 +2350,7 @@ class MachineCom(object): return get("temperature", busy_default) - def _sendFromQueue(self): + def _send_from_command_queue(self): # We loop here to make sure that if we do NOT send the first command # from the queue, we'll send the second (if there is one). We do not # want to get stuck here by throwing away commands. @@ -2587,7 +2596,7 @@ class MachineCom(object): return ret - def _getNext(self): + def _get_next_from_job(self): if self._currentFile is None: return None @@ -2603,7 +2612,7 @@ class MachineCom(object): return SendQueueMarker(finalize), None, None return line, pos, lineno - def _sendNext(self): + def _send_from_job(self): with self._jobLock: while self._active: # we loop until we've actually enqueued a line for sending @@ -2615,7 +2624,7 @@ class MachineCom(object): # job is on hold, return false return False - line, pos, lineno = self._getNext() + line, pos, lineno = self._get_next_from_job() if isinstance(line, QueueMarker): self.sendCommand(line) self._callback.on_comm_progress() @@ -2631,11 +2640,23 @@ class MachineCom(object): result = self._sendCommand(line, tags={"source:file", "filepos:{}".format(pos), "fileline:{}".format(lineno)}) self._callback.on_comm_progress() if result: - # line sent, return true + # line from file sent, return true return True self._logger.debug("Command \"{}\" from file not enqueued, doing another iteration".format(line)) + def _send_from_script_queue(self): + try: + line, tags = self._script_queue.get_nowait() + result = self._sendCommand(line, tags=tags) + if result: + # line from script sent, return true + return True + except queue.Empty: + pass + + return False + def _handle_resend_request(self, line): try: lineToResend = parse_resend_line(line) @@ -3806,6 +3827,9 @@ class SpecialStreamingGcodeFileInformation(StreamingGcodeFileInformation): return None return line +class ScriptQueue(PrependableQueue): + pass + class CommandQueue(TypedQueue): def __init__(self, *args, **kwargs): TypedQueue.__init__(self, *args, **kwargs) From 85ef3f1df2fd55ab9c80822764998d8016c52532 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Sat, 9 Jun 2018 13:07:34 +0200 Subject: [PATCH 06/34] Fix modals not hiding fully anymore --- src/octoprint/static/js/app/helpers.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/octoprint/static/js/app/helpers.js b/src/octoprint/static/js/app/helpers.js index 49af106bc..1eb161d05 100644 --- a/src/octoprint/static/js/app/helpers.js +++ b/src/octoprint/static/js/app/helpers.js @@ -674,7 +674,6 @@ function showMessageDialog(msg, options) { if (onclose && _.isFunction(onclose)) { onclose(); } - modal.remove(); }); if (onshow) { @@ -749,7 +748,6 @@ function showConfirmationDialog(msg, onacknowledge, options) { onproceed(e); } modal.modal("hide"); - modal.remove(); }); return modal; @@ -834,7 +832,6 @@ function showSelectionDialog(options) { if (onclose && _.isFunction(onclose)) { onclose(event); } - modal.remove(); }); modal.modal("show"); From 392149b5047a9adf2ff94aff0b94ce2dbc25f936 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 14 Jun 2018 19:25:46 +0200 Subject: [PATCH 07/34] Add view model list to coreui object --- src/octoprint/static/js/app/main.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/octoprint/static/js/app/main.js b/src/octoprint/static/js/app/main.js index 5f980c3f7..cdd1886f8 100644 --- a/src/octoprint/static/js/app/main.js +++ b/src/octoprint/static/js/app/main.js @@ -49,7 +49,8 @@ $(function() { mobile: false, desktop: false - } + }, + viewmodels: {} }; var browserVisibilityCallbacks = []; @@ -400,6 +401,7 @@ $(function() { pass++; } log.info("... dependency resolution done"); + OctoPrint.coreui.viewmodels = viewModelMap; //~~ some additional hooks and initializations From 86b886ede72dff8c3d96cae424ecba7464edee9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 15 Jun 2018 12:32:07 +0200 Subject: [PATCH 08/34] Remove resend repetition code It's apparently completely broken and the fact that no one noticed and reported that means it never really gets used either from the looks of it. So instead of allowing it to introduce broken resend handling, we'll rather remove it for now. --- src/octoprint/plugins/virtual_printer/virtual.py | 2 -- src/octoprint/settings.py | 1 - src/octoprint/util/comm.py | 13 ------------- 3 files changed, 16 deletions(-) diff --git a/src/octoprint/plugins/virtual_printer/virtual.py b/src/octoprint/plugins/virtual_printer/virtual.py index 7531df71e..e1aa40202 100644 --- a/src/octoprint/plugins/virtual_printer/virtual.py +++ b/src/octoprint/plugins/virtual_printer/virtual.py @@ -680,8 +680,6 @@ class VirtualPrinter(object): if not self._brokenResend: self._sendOk() - if settings().getBoolean(["devel", "virtualPrinter", "repetierStyleResends"]): - request_resend() request_resend() def _debugTrigger(self, data): diff --git a/src/octoprint/settings.py b/src/octoprint/settings.py index af433e9f4..498e4c025 100644 --- a/src/octoprint/settings.py +++ b/src/octoprint/settings.py @@ -382,7 +382,6 @@ default_settings = { "includeFilenameInOpened": True, "hasBed": True, "repetierStyleTargetTemperature": False, - "repetierStyleResends": False, "okBeforeCommandOutput": False, "smoothieTemperatureReporting": False, "reprapfwM114": False, diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index 64032f1d0..62010267d 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -445,8 +445,6 @@ class MachineCom(object): self._lastCommError = None self._lastResendNumber = None self._currentResendCount = 0 - self._resendSwallowRepetitions = settings().getBoolean(["serial", "ignoreIdenticalResends"]) - self._resendSwallowRepetitionsCounter = 0 self._firmware_detection = settings().getBoolean(["serial", "firmwareDetection"]) self._firmware_info_received = not self._firmware_detection @@ -1771,7 +1769,6 @@ class MachineCom(object): self._logger.info("Detected Repetier firmware, enabling relevant features for issue free communication") self._alwaysSendChecksum = True - self._resendSwallowRepetitions = True self._blockWhileDwelling = True supportRepetierTargetTemp = True disable_external_heatup_detection = True @@ -2696,20 +2693,10 @@ class MachineCom(object): self._currentResendCount += 1 return True - # If we ignore resend repetitions (Repetier firmware...), check if we - # need to do this now. If the same line number has been requested we - # already saw and resent, we'll ignore it up to times. - if self._resendSwallowRepetitions and lineToResend == self._lastResendNumber and self._resendSwallowRepetitionsCounter > 0: - self._logger.info("Ignoring resend request for line %d, that is probably a repetition sent by the " - "firmware to ensure it arrives, not a real request" % lineToResend) - self._resendSwallowRepetitionsCounter -= 1 - return True - self._resendActive = True self._resendDelta = resendDelta self._lastResendNumber = lineToResend self._currentResendCount = 0 - self._resendSwallowRepetitionsCounter = settings().getInt(["serial", "identicalResendsCountdown"]) if self._resendDelta > len(self._lastLines) or len(self._lastLines) == 0 or self._resendDelta < 0: error_text = "Printer requested line %d but no sufficient history is available, can't resend" % lineToResend From 688e4d36d1dbbf4a4fc1cdd749582614d0ce0bab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Sat, 9 Jun 2018 14:24:19 +0200 Subject: [PATCH 09/34] Fix script order beforePrint* should always precede any commands from the print job. Also make sure we only jump from "finishing" to "operational" after the afterPrintDone script has been sent. Also wait for all moves to finish. --- src/octoprint/util/comm.py | 123 +++++++++++++++++++------------------ 1 file changed, 63 insertions(+), 60 deletions(-) diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index 62010267d..bf347ad80 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -481,7 +481,7 @@ class MachineCom(object): self._temperature_timer = None self._sd_status_timer = None - self._script_queue = ScriptQueue() + self._job_queue = JobQueue() # hooks self._pluginManager = octoprint.plugin.plugin_manager() @@ -884,7 +884,7 @@ class MachineCom(object): def fakeOk(self): self._handle_ok() - def sendCommand(self, cmd, cmd_type=None, processed=False, force=False, on_sent=None, tags=None): + def sendCommand(self, cmd, cmd_type=None, part_of_job=False, processed=False, force=False, on_sent=None, tags=None): if not isinstance(cmd, QueueMarker): cmd = to_unicode(cmd, errors="replace") if not processed: @@ -892,7 +892,13 @@ class MachineCom(object): if not cmd: return False - if self.isPrinting() and not self.isSdFileSelected() and not self.job_on_hold and not force: + if tags is None: + tags = set() + + if part_of_job: + self._job_queue.put((cmd, cmd_type, on_sent, tags | {"source:job"})) + return True + elif self.isPrinting() and not self.isSdFileSelected() and not self.job_on_hold and not force: try: self._command_queue.put((cmd, cmd_type, on_sent, tags), item_type=cmd_type) return True @@ -975,10 +981,7 @@ class MachineCom(object): scriptLines = self._getGcodeScript(scriptName, replacements=replacements) tags_to_use = tags | {"trigger:comm.send_gcode_script", "source:script", "script:{}".format(scriptName)} for line in scriptLines: - if part_of_job: - self._script_queue.put((line, tags_to_use)) - else: - self.sendCommand(line, tags=tags_to_use) + self.sendCommand(line, part_of_job=part_of_job, tags=tags_to_use) return "\n".join(scriptLines) def startPrint(self, pos=None, tags=None, external_sd=False): @@ -1003,7 +1006,7 @@ class MachineCom(object): self._changeState(self.STATE_PRINTING) if not self.isSdFileSelected(): - self.resetLineNumbers(tags={"trigger:comm.start_print"}) + self.resetLineNumbers(part_of_job=True, tags={"trigger:comm.start_print"}) self._callback.on_comm_print_job_started() @@ -1012,14 +1015,19 @@ class MachineCom(object): # make sure to ignore the "file selected" later on, otherwise we'll reset our progress data self._ignore_select = True self.sendCommand("M23 {filename}".format(filename=self._currentFile.getFilename()), + part_of_job=True, tags=tags | {"trigger:comm.start_print",}) if pos is not None and isinstance(pos, int) and pos > 0: self._currentFile.pos = pos - self.sendCommand("M26 S{}".format(pos), tags=tags | {"trigger:comm.start_print",}) + self.sendCommand("M26 S{}".format(pos), + part_of_job=True, + tags=tags | {"trigger:comm.start_print",}) else: self._currentFile.pos = 0 - self.sendCommand("M24", tags=tags | {"trigger:comm.start_print",}) + self.sendCommand("M24", + part_of_job=True, + tags=tags | {"trigger:comm.start_print",}) interval = self._timeout_intervals.get("sdStatus", 1.0) if interval <= 0: @@ -1030,15 +1038,8 @@ class MachineCom(object): if pos is not None and isinstance(pos, int) and pos > 0: self._currentFile.seek(pos) - line, pos, lineno = self._get_next_from_job() - if line is not None: - self.sendCommand(line, tags=tags | {"trigger:comm.start_print", - "source:file", - "filepos:{}".format(pos), - "fileline:{}".format(lineno)}) - # now make sure we actually do something, up until now we only filled up the queue - self._send_from_command_queue() + self._continue_sending() except: self._logger.exception("Error while trying to start printing") self._trigger_error(get_exception_string(), "start_print") @@ -1152,7 +1153,7 @@ class MachineCom(object): def finalize(): self._changeState(self.STATE_OPERATIONAL) - self.sendCommand(SendQueueMarker(finalize)) + self.sendCommand(SendQueueMarker(finalize), part_of_job=True) self._continue_sending() def cancelPrint(self, firmware_error=None, disable_log_position=False, tags=None, external_sd=False): @@ -1184,8 +1185,8 @@ class MachineCom(object): self._cancel_preparation_failed) self._cancel_position_timer.daemon = True self._cancel_position_timer.start() - self.sendCommand("M114", tags=tags | {"trigger:comm.cancel", - "trigger:record_position"}) + self.sendCommand("M114", part_of_job=True, tags=tags | {"trigger:comm.cancel", + "trigger:record_position"}) self._callback.on_comm_print_job_cancelling(firmware_error=firmware_error) @@ -1194,9 +1195,9 @@ class MachineCom(object): if self.isSdFileSelected(): if not external_sd: - self.sendCommand("M25", tags=tags | {"trigger:comm.cancel",}) # pause print - self.sendCommand("M27", tags=tags | {"trigger:comm.cancel",}) # get current byte position in file - self.sendCommand("M26 S0", tags=tags | {"trigger:comm.cancel",}) # reset position in file to byte 0 + self.sendCommand("M25", part_of_job=True, tags=tags | {"trigger:comm.cancel",}) # pause print + self.sendCommand("M27", part_of_job=True, tags=tags | {"trigger:comm.cancel",}) # get current byte position in file + self.sendCommand("M26 S0", part_of_job=True, tags=tags | {"trigger:comm.cancel",}) # reset position in file to byte 0 if self._sd_status_timer is not None: try: self._sd_status_timer.cancel() @@ -1205,9 +1206,10 @@ class MachineCom(object): if self._log_position_on_cancel and not disable_log_position: self.sendCommand("M400", - on_sent=_on_M400_sent, - tags=tags | {"trigger:comm.cancel", - "trigger:record_position"}) + on_sent=_on_M400_sent, + part_of_job=True, + tags=tags | {"trigger:comm.cancel", + "trigger:record_position"}) self._continue_sending() else: self._cancel_preparation_done(check_timer=False) @@ -1237,7 +1239,7 @@ class MachineCom(object): def finalize(): self._changeState(self.STATE_PAUSED) - self.sendCommand(SendQueueMarker(finalize)) + self.sendCommand(SendQueueMarker(finalize), part_of_job=True) self._continue_sending() def setPause(self, pause, local_handling=True, tags=None): @@ -1258,26 +1260,19 @@ class MachineCom(object): self._changeState(self.STATE_RESUMING) self._callback.on_comm_print_job_resumed(suppress_script=not local_handling) - self.sendCommand(SendQueueMarker(lambda: self._changeState(self.STATE_PRINTING))) + self.sendCommand(SendQueueMarker(lambda: self._changeState(self.STATE_PRINTING)), part_of_job=True) if self.isSdFileSelected(): if local_handling: - self.sendCommand("M24", tags=tags | {"trigger:comm.set_pause","trigger:resume"}) - self.sendCommand("M27", tags=tags | {"trigger:comm.set_pause", "trigger:resume"}) - else: - line, pos, lineno = self._get_next_from_job() - if line is not None: - if not tags: - tags = set() - tags_to_use = tags | {"trigger:comm.set_pause", - "trigger:resume", - "source:file", - "filepos:{}".format(pos), - "fileline:{}".format(lineno)} - self.sendCommand(line, tags=tags_to_use) + self.sendCommand("M24", + part_of_job=True, + tags=tags | {"trigger:comm.set_pause","trigger:resume"}) + self.sendCommand("M27", + part_of_job=True, + tags=tags | {"trigger:comm.set_pause", "trigger:resume"}) # now make sure we actually do something, up until now we only filled up the queue - self._send_from_command_queue() + self._continue_sending() elif pause and self.isPrinting(): if not self._pauseWaitStartTime: @@ -1285,7 +1280,9 @@ class MachineCom(object): self._changeState(self.STATE_PAUSING) if self.isSdFileSelected() and local_handling: - self.sendCommand("M25", tags=tags | {"trigger:comm.set_pause", "trigger:pause"}) # pause print + self.sendCommand("M25", + part_of_job=True, + tags=tags | {"trigger:comm.set_pause", "trigger:pause"}) # pause print if not local_handling: with self._suppress_scripts_mutex: @@ -1305,16 +1302,19 @@ class MachineCom(object): self._pause_preparation_failed) self._pause_position_timer.daemon = True self._pause_position_timer.start() - self.sendCommand("M114", tags=tags | {"trigger:comm.set_pause", - "trigger:pause", - "trigger:record_position"}) + self.sendCommand("M114", + part_of_job=True, + tags=tags | {"trigger:comm.set_pause", + "trigger:pause", + "trigger:record_position"}) if self._log_position_on_pause: self.sendCommand("M400", - on_sent=_on_M400_sent, - tags=tags | {"trigger:comm.set_pause", - "trigger:pause", - "trigger:record_position"}) + on_sent=_on_M400_sent, + part_of_job=True, + tags=tags | {"trigger:comm.set_pause", + "trigger:pause", + "trigger:record_position"}) self._continue_sending() else: self._pause_preparation_done(check_timer=False, suppress_script=not local_handling) @@ -1391,14 +1391,16 @@ class MachineCom(object): self.sendCommand(self._hello_command, force=True, tags=tags | {"trigger:comm.say_hello",}) self._clear_to_send.set() - def resetLineNumbers(self, number=0, tags=None): + def resetLineNumbers(self, number=0, part_of_job=False, tags=None): if not self.isOperational(): return if tags is None: tags = set() - self.sendCommand("M110 N%d" % number, tags=tags | {"trigger:comm.reset_line_numbers",}) + self.sendCommand("M110 N{}".format(number), + part_of_job=part_of_job, + tags=tags | {"trigger:comm.reset_line_numbers",}) ##~~ record aborted file positions @@ -2187,7 +2189,7 @@ class MachineCom(object): # job is on hold, that means we must not send from either script queue or file return False - elif self._send_from_script_queue(): + elif self._send_from_job_queue(): # we found something in the script queue to send return True @@ -2595,7 +2597,7 @@ class MachineCom(object): def _get_next_from_job(self): if self._currentFile is None: - return None + return None, None, None line, pos, lineno = self._currentFile.getNext() if line is None: @@ -2603,6 +2605,7 @@ class MachineCom(object): self._finishFileTransfer() else: self._changeState(self.STATE_FINISHING) + self.sendCommand("M400", part_of_job=True) self._callback.on_comm_print_job_done() def finalize(): self._changeState(self.STATE_OPERATIONAL) @@ -2623,7 +2626,7 @@ class MachineCom(object): line, pos, lineno = self._get_next_from_job() if isinstance(line, QueueMarker): - self.sendCommand(line) + self.sendCommand(line, part_of_job=True) self._callback.on_comm_progress() # end of file, return false so that the next round in continue_sending will process @@ -2642,10 +2645,10 @@ class MachineCom(object): self._logger.debug("Command \"{}\" from file not enqueued, doing another iteration".format(line)) - def _send_from_script_queue(self): + def _send_from_job_queue(self): try: - line, tags = self._script_queue.get_nowait() - result = self._sendCommand(line, tags=tags) + line, cmd_type, on_sent, tags = self._job_queue.get_nowait() + result = self._sendCommand(line, cmd_type=cmd_type, on_sent=on_sent, tags=tags) if result: # line from script sent, return true return True @@ -3814,7 +3817,7 @@ class SpecialStreamingGcodeFileInformation(StreamingGcodeFileInformation): return None return line -class ScriptQueue(PrependableQueue): +class JobQueue(PrependableQueue): pass class CommandQueue(TypedQueue): From 17c6c83503e4526762d0ef9f1cdff6023f0f1247 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 15 Jun 2018 17:02:53 +0200 Subject: [PATCH 10/34] Fix SD printing --- .../plugins/virtual_printer/virtual.py | 2 +- src/octoprint/printer/standard.py | 8 ++++-- src/octoprint/util/comm.py | 27 ++++++++++++------- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/octoprint/plugins/virtual_printer/virtual.py b/src/octoprint/plugins/virtual_printer/virtual.py index e1aa40202..e37785151 100644 --- a/src/octoprint/plugins/virtual_printer/virtual.py +++ b/src/octoprint/plugins/virtual_printer/virtual.py @@ -1158,10 +1158,10 @@ class VirtualPrinter(object): def _finishSdPrint(self): if not self._killed: self._sdPrintingSemaphore.clear() + self._output("Done printing file") self._selectedSdFilePos = 0 self._sdPrinting = False self._sdPrinter = None - self._output("Done printing file") def _waitForHeatup(self, heater, only_wait_if_higher): delta = 1 diff --git a/src/octoprint/printer/standard.py b/src/octoprint/printer/standard.py index 7de61daeb..c1355bbad 100644 --- a/src/octoprint/printer/standard.py +++ b/src/octoprint/printer/standard.py @@ -440,8 +440,12 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): self._validateJob(path, sd) origin = FileDestinations.SDCARD if sd else FileDestinations.LOCAL - path_on_disk = self._fileManager.path_on_disk(origin, path) - path_in_storage = self._fileManager.path_in_storage(origin, path_on_disk) + if sd: + path_on_disk = "/" + path + path_in_storage = path + else: + path_on_disk = self._fileManager.path_on_disk(origin, path) + path_in_storage = self._fileManager.path_in_storage(origin, path_on_disk) recovery_data = self._fileManager.get_recovery_data() if recovery_data: diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index bf347ad80..e595d5746 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -1011,9 +1011,15 @@ class MachineCom(object): self._callback.on_comm_print_job_started() if self.isSdFileSelected(): + interval = self._timeout_intervals.get("sdStatus", 1.0) + if interval <= 0: + interval = 1.0 + self._sd_status_timer = RepeatedTimer(interval, self._poll_sd_status, run_first=True) + if not external_sd: # make sure to ignore the "file selected" later on, otherwise we'll reset our progress data self._ignore_select = True + self.sendCommand("M23 {filename}".format(filename=self._currentFile.getFilename()), part_of_job=True, tags=tags | {"trigger:comm.start_print",}) @@ -1025,15 +1031,15 @@ class MachineCom(object): else: self._currentFile.pos = 0 + def start_polling(): + self._sd_status_timer.start() + self.sendCommand("M24", + on_sent=start_polling, part_of_job=True, tags=tags | {"trigger:comm.start_print",}) - - interval = self._timeout_intervals.get("sdStatus", 1.0) - if interval <= 0: - interval = 1.0 - self._sd_status_timer = RepeatedTimer(interval, self._poll_sd_status, run_first=True) - self._sd_status_timer.start() + else: + self._sd_status_timer.start() else: if pos is not None and isinstance(pos, int) and pos > 0: self._currentFile.seek(pos) @@ -1890,7 +1896,7 @@ class MachineCom(object): self._currentFile.size = total self._callback.on_comm_progress() - elif 'Not SD printing' in line and self.isSdFileSelected() and self.isPrinting(): + elif 'Not SD printing' in line and self.isSdFileSelected() and self.isPrinting() and not self.isFinishing(): # something went wrong, printer is reporting that we actually are not printing right now... self.cancelPrint(external_sd=True) elif 'File opened' in line and not self._ignore_select: @@ -1933,6 +1939,8 @@ class MachineCom(object): self._changeState(self.STATE_PRINTING) elif 'Done printing file' in line and self.isSdPrinting(): # printer is reporting file finished printing + self._changeState(self.STATE_FINISHING) + self._currentFile.done = True self._currentFile.pos = 0 @@ -1942,11 +1950,12 @@ class MachineCom(object): except: pass - self._changeState(self.STATE_FINISHING) + self.sendCommand("M400", part_of_job=True) self._callback.on_comm_print_job_done() def finalize(): self._changeState(self.STATE_OPERATIONAL) - self.sendCommand(SendQueueMarker(finalize)) + self.sendCommand(SendQueueMarker(finalize), part_of_job=True) + self._continue_sending() elif 'Done saving file' in line: if self._trigger_ok_for_m29: # workaround for most versions of Marlin out in the wild From fe2dbf699d15985a008442bc1b635f603f3a76fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 15 Jun 2018 18:15:13 +0200 Subject: [PATCH 11/34] SWU: Lock down UI while updating Implements #1217 --- .../plugins/softwareupdate/static/js/softwareupdate.js | 4 +--- .../softwareupdate/templates/softwareupdate_settings.jinja2 | 4 +++- src/octoprint/static/js/app/viewmodels/printerstate.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js b/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js index 6a1192f43..d0484a5b8 100644 --- a/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js +++ b/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js @@ -399,8 +399,6 @@ $(function() { }; self.performCheck = function(showIfNothingNew, force, ignoreSeen) { - if (!self.loginState.isAdmin() && !self.settings.settings.plugins.softwareupdate.notify_users()) return; - self.checking(true); OctoPrint.plugins.softwareupdate.check(force) .done(function(data) { @@ -590,7 +588,7 @@ $(function() { }; self._showWorkingDialog = function(title) { - if (!self.loginState.isAdmin()) { + if (!self.loginState.isAdmin() && !self.loginState.isUser()) { return; } diff --git a/src/octoprint/plugins/softwareupdate/templates/softwareupdate_settings.jinja2 b/src/octoprint/plugins/softwareupdate/templates/softwareupdate_settings.jinja2 index 68b61d78a..106d64bc5 100644 --- a/src/octoprint/plugins/softwareupdate/templates/softwareupdate_settings.jinja2 +++ b/src/octoprint/plugins/softwareupdate/templates/softwareupdate_settings.jinja2 @@ -111,7 +111,9 @@