Skip to content

Commit

Permalink
job.filament can be None sometimes, so avoid that (see issue #6)
Browse files Browse the repository at this point in the history
  • Loading branch information
agrif committed Mar 24, 2020
1 parent e0f6c40 commit 1c48600
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion octoprint_influxdb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,10 @@ def add_to(d, k, x):
add_to(fields, 'state', data.get('state', {}).get('text'))
add_to(fields, 'average_print_time', job.get('averagePrintTime'))
add_to(fields, 'estimated_print_time', job.get('estimatedPrintTime'))
for filname, filval in job.get('filament', {}).items():
filaments = job.get('filament')
if not filaments:
filaments = {}
for filname, filval in filaments.items():
add_to(fields, 'filament_' + filname + '_length', filval.get('length'))
add_to(fields, 'filament_' + filname + '_volume', filval.get('volume'))
add_to(fields, 'file_date', jobfile.get('date'))
Expand Down

0 comments on commit 1c48600

Please sign in to comment.