summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Baumann <derflob@derflob.de>2016-07-15 22:33:05 +1200
committerFlorian Baumann <derflob@derflob.de>2016-07-15 22:33:05 +1200
commitee65a18c183317d97398065ba78b3ef990362a1a (patch)
tree43fc419933a1b26f6777fc68b47354d378b4f0ed
parent088cadada16548732c3613156c843c475753ae65 (diff)
downloadxmpp-ee65a18c183317d97398065ba78b3ef990362a1a.tar.gz
xmpp-ee65a18c183317d97398065ba78b3ef990362a1a.tar.bz2
job['filament'] may be None
-rw-r--r--__init__.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/__init__.py b/__init__.py
index b5ed95f..df39bbb 100644
--- a/__init__.py
+++ b/__init__.py
@@ -161,7 +161,7 @@ class OctoXMPP(EventHandlerPlugin, SettingsPlugin):
def _status_job(self):
state = self._printer.get_current_data()
- lines = ["Job state:\n"]
+ lines = ["Job state:"]
if (state['job']['file']['origin']):
lines.append("File: {}".format(state['job']['file']['name']))
flags = state['state']['flags']
@@ -180,13 +180,14 @@ class OctoXMPP(EventHandlerPlugin, SettingsPlugin):
lines.append("Printing for {printTime}.".format(
self.__format_duration(state['progress']['printTime'])))
- for (k, v) in state['job']['filament'].items():
- if (v['length'] > 1000.0):
- lines.append("Filament ({}): {:.1f}cm³/{:.2f}m".format(
- k, v['volume'], v['length']/1000.0))
- else:
- lines.append("Filament ({}): {:.1f}cm³/{:.0f}mm".format(
- k, v['volume'], v['length']))
+ if (state['job']['filament']):
+ for (k, v) in state['job']['filament'].items():
+ if (v['length'] > 1000.0):
+ lines.append("Filament ({}): {:.1f}cm³/{:.2f}m".format(
+ k, v['volume'], v['length']/1000.0))
+ else:
+ lines.append("Filament ({}): {:.1f}cm³/{:.0f}mm".format(
+ k, v['volume'], v['length']))
else:
lines.append("No job loaded.")