From b252da477cd102ce502b615b0496908412b3bac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 22 Nov 2017 12:49:58 +0100 Subject: [PATCH] Virtual printer: allow empty/None prepared oks --- src/octoprint/plugins/virtual_printer/virtual.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/octoprint/plugins/virtual_printer/virtual.py b/src/octoprint/plugins/virtual_printer/virtual.py index 66fc05d016..dac7457fc0 100644 --- a/src/octoprint/plugins/virtual_printer/virtual.py +++ b/src/octoprint/plugins/virtual_printer/virtual.py @@ -424,7 +424,9 @@ def _gcode_M30(self, data): def _gcode_M114(self, data): output = "X:{} Y:{} Z:{} E:{} Count: A:{} B:{} C:{}".format(self._lastX, self._lastY, self._lastZ, self._lastE, int(self._lastX*100), int(self._lastY*100), int(self._lastZ*100)) if not self._okBeforeCommandOutput: - output = "{} {}".format(self._ok(), output) + ok = self._ok() + if ok: + output = "{} {}".format(self._ok(), output) self._send(output) return True @@ -555,7 +557,7 @@ def _triggerResend(self, expected=None, actual=None, checksum=None): def request_resend(): self._send("Resend:%d" % expected) - self._send(self._ok()) + self._sendOk() if settings().getBoolean(["devel", "virtualPrinter", "repetierStyleResends"]): request_resend() @@ -772,7 +774,9 @@ def _processTemperatureQuery(self): output = self._generateTemperatureOutput() if includeOk: - output = "{} {}".format(self._ok(), output) + ok = self._ok() + if ok: + output = "{} {}".format(ok, output) self._send(output) def _parseHotendCommand(self, line, wait=False, support_r=False): @@ -1156,7 +1160,9 @@ def close(self): def _sendOk(self): if self.outgoing is None: return - self._send(self._ok()) + ok = self._ok() + if ok: + self._send(ok) def _sendWaitAfterTimeout(self, timeout=5): time.sleep(timeout) @@ -1171,6 +1177,8 @@ def _ok(self): ok = self._okFormatString if self._prepared_oks: ok = self._prepared_oks.pop(0) + if ok is None: + return ok return ok.format(ok, lastN=self.lastN, buffer=self.buffered.maxsize - self.buffered.qsize())