Skip to content

Commit

Permalink
fix the crash in a case of non-existent filament data
Browse files Browse the repository at this point in the history
  • Loading branch information
bkralik authored and agrif committed May 3, 2024
1 parent c2a4e8b commit 0806c6c
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions octoprint_influxdb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,16 +303,17 @@ def add_to(d, k, x):
if job.get('file', {}).get('name'):
# a file is loaded...
filename = job['file']['name']
filaments = job.get('filament')
for tool, filval in filaments.items():
fields = { }
tags = {}
add_to(fields, 'length', filval.get('length'))
add_to(fields, 'volume', filval.get('volume'))
add_to(tags, 'filename', filename)
add_to(tags, 'tool', tool)
if fields:
self.influx_emit('filament', fields, tags)
if job.get('filament'):
filaments = job.get('filament')
for tool, filval in filaments.items():
fields = { }
tags = {}
add_to(fields, 'length', filval.get('length'))
add_to(fields, 'volume', filval.get('volume'))
add_to(tags, 'filename', filename)
add_to(tags, 'tool', tool)
if fields:
self.influx_emit('filament', fields, tags)

##~~ EventHandlerPlugin mixin

Expand Down

0 comments on commit 0806c6c

Please sign in to comment.