From fb8fecec3398009a3e722a210ad2142b56fb894b Mon Sep 17 00:00:00 2001 From: clemniem Date: Mon, 12 Sep 2016 15:43:12 +0200 Subject: [PATCH] Fixed KeyError in events.py that prevented a command associated with the ClientOpened event from execution. The if-statement checked against currentData["job"] is not None, although it was not None even if there was no job. --- AUTHORS.md | 1 + src/octoprint/events.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/AUTHORS.md b/AUTHORS.md index 13a7552e..3408d14f 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -72,6 +72,7 @@ date of first contribution): * [Ovidiu Hossu](https://github.com/MoonshineSG) * [Eyck Jentzsch](https://github.com/eyck) * [Mathias Rangel Wulff](https://github.com/mathiasrw) + * [Clemens Niemeyer](https://github.com/clemniem) 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/events.py b/src/octoprint/events.py index bcff3a73..3a1cbefe 100644 --- a/src/octoprint/events.py +++ b/src/octoprint/events.py @@ -386,7 +386,8 @@ class CommandTrigger(GenericEventListener): if "currentZ" in currentData.keys() and currentData["currentZ"] is not None: params["__currentZ"] = str(currentData["currentZ"]) - if "job" in currentData.keys() and currentData["job"] is not None: + if "job" in currentData and "file" in currentData["job"] and "name" in currentData["job"]["file"] \ + and currentData["job"]["file"]["name"] is not None: params["__filename"] = currentData["job"]["file"]["name"] params["__filepath"] = currentData["job"]["file"]["path"] params["__fileorigin"] = currentData["job"]["file"]["origin"]