Handle marker attrs that may not exist (#27519)

marker-high-levels and marker-low-levels may not exist in printer
attributes returned by CUPS, so we'll use .get() to avoid this and
default to None:
KeyError: 'marker-high-levels'

Fixes #27518
This commit is contained in:
Brett T. Warden 2019-10-15 02:53:13 -07:00 committed by Fabian Affolter
parent 5b410ff3a5
commit 57b8d1889a

View File

@ -276,11 +276,11 @@ class MarkerSensor(Entity):
if self._attributes is None: if self._attributes is None:
return None return None
high_level = self._attributes[self._printer]["marker-high-levels"] high_level = self._attributes[self._printer].get("marker-high-levels")
if isinstance(high_level, list): if isinstance(high_level, list):
high_level = high_level[self._index] high_level = high_level[self._index]
low_level = self._attributes[self._printer]["marker-low-levels"] low_level = self._attributes[self._printer].get("marker-low-levels")
if isinstance(low_level, list): if isinstance(low_level, list):
low_level = low_level[self._index] low_level = low_level[self._index]