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.
This commit is contained in:
clemniem 2016-09-12 15:43:12 +02:00
parent f19457532f
commit fb8fecec33
2 changed files with 3 additions and 1 deletions

View file

@ -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

View file

@ -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"]