From 388e45ae11e24469d744a7b4aae216845130ac0d Mon Sep 17 00:00:00 2001 From: kaenguruhs <79077545+kaenguruhs@users.noreply.github.com> Date: Tue, 20 Jun 2023 13:48:38 +0200 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B=20Fix=20context=20variables=20?= =?UTF-8?q?in=20GCODE=20scripts=20from=20multiple=20plugins=20(#4757)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * provide variables from multiple plugins * 🎨 Fix linter issues --------- Co-authored-by: Gina Häußge Closes #4756 --- AUTHORS.md | 1 + src/octoprint/util/comm.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/AUTHORS.md b/AUTHORS.md index 4de369152..150279e67 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -178,6 +178,7 @@ date of first contribution): * [Shyam Sunder](https://github.com/sgsunder) * [Conny Rasch](https://github.com/CMR-DEV) * [Christopher Perrin](https://github.com/cperrin88) + * [Martin Bartsch](https://github.com/kaenguruhs) OctoPrint started off as a fork of [Cura](https://github.com/daid/Cura) by [Daid Braam](https://github.com/daid). Parts of its communication layer and diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index 74ed974d2..a4841b96b 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -36,6 +36,7 @@ from octoprint.util import ( TypeAlreadyInQueue, TypedQueue, chunks, + dict_merge, filter_non_ascii, filter_non_utf8, get_bom, @@ -1380,7 +1381,7 @@ class MachineCom: if len(retval) == 3: variables = retval[2] - context.update({"plugins": {name: variables}}) + context = dict_merge(context, {"plugins": {name: variables}}) template = settings().loadScript("gcode", scriptName, context=context) if template is None: From c0c6b6829a0204cbf155b391dab8e8d5faed01e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20W=C3=BCrthner?= Date: Tue, 20 Jun 2023 17:03:02 +0200 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=90=9B=20Ensure=20subscription=20chan?= =?UTF-8?q?ges=20cause=20a=20history=20message=20(#4752)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/octoprint/server/util/sockjs.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/octoprint/server/util/sockjs.py b/src/octoprint/server/util/sockjs.py index 3140887d7..834bbb972 100644 --- a/src/octoprint/server/util/sockjs.py +++ b/src/octoprint/server/util/sockjs.py @@ -381,10 +381,12 @@ class PrinterStateConnection( self._subscriptions["plugins"] = plugins self._subscriptions["events"] = events - if state and not old_state: - # trigger initial data + if state and state != old_state: + # state is requested and was changed from previous state + # we should send a history message to send the update data self._printer.send_initial_callback(self) elif old_state and not state: + # we no longer should send state updates self._initial_data_sent = False def on_printer_send_current_data(self, data):