From d15262e7cc7c5f438842e3ac9a672401c7e0d7a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 22 Feb 2017 17:58:21 +0100 Subject: [PATCH] Fixed wrong replacement for __progress placeholder in events Data reported from printer backend is already percent, multiplying it with 100 again produces wrong values. --- src/octoprint/events.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/octoprint/events.py b/src/octoprint/events.py index b8f12ad0..a117c844 100644 --- a/src/octoprint/events.py +++ b/src/octoprint/events.py @@ -397,7 +397,7 @@ class CommandTrigger(GenericEventListener): currentData = self._printer.get_current_data() - if "currentZ" in currentData.keys() and currentData["currentZ"] is not None: + if "currentZ" in currentData and currentData["currentZ"] is not None: params["__currentZ"] = str(currentData["currentZ"]) if "job" in currentData and "file" in currentData["job"] and "name" in currentData["job"]["file"] \ @@ -405,9 +405,9 @@ class CommandTrigger(GenericEventListener): params["__filename"] = currentData["job"]["file"]["name"] params["__filepath"] = currentData["job"]["file"]["path"] params["__fileorigin"] = currentData["job"]["file"]["origin"] - if "progress" in currentData.keys() and currentData["progress"] is not None \ - and "completion" in currentData["progress"].keys() and currentData["progress"]["completion"] is not None: - params["__progress"] = str(round(currentData["progress"]["completion"] * 100)) + if "progress" in currentData and currentData["progress"] is not None \ + and "completion" in currentData["progress"] and currentData["progress"]["completion"] is not None: + params["__progress"] = str(round(currentData["progress"]["completion"])) # now add the payload keys as well if isinstance(payload, dict):