Skip to content

Commit

Permalink
Add resilience against printer profiles with missing info
Browse files Browse the repository at this point in the history
  • Loading branch information
fieldOfView committed Dec 30, 2021
1 parent bc7ae9c commit 910a11c
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions OctoPrintOutputDevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -929,14 +929,19 @@ def _onRequestFinished(self, reply: QNetworkReply) -> None:

for profile_id in json_data["profiles"]:
printer_profile = json_data["profiles"][profile_id]
if printer_profile["current"]:
self._printer_name = printer_profile["name"]
self._printer_model = printer_profile["model"]

for axis in ["x", "y", "z", "e"]:
self._axis_information[axis] = AxisInformation(
speed=printer_profile["axes"][axis]["speed"],
inverted=printer_profile["axes"][axis]["inverted"],
if printer_profile.get("current", False):
self._printer_name = printer_profile.get("name", "")
self._printer_model = printer_profile.get("model", "")

try:
for axis in ["x", "y", "z", "e"]:
self._axis_information[axis] = AxisInformation(
speed=printer_profile["axes"][axis]["speed"],
inverted=printer_profile["axes"][axis]["inverted"],
)
except KeyError:
Logger.log(
"w", "Unable to retreive axes information from OctoPrint printer profile."
)

self.additionalDataChanged.emit()
Expand Down

0 comments on commit 910a11c

Please sign in to comment.