Skip to content

Commit 5467376

Browse files
committed
Refactor PrintJobTracker to improve handling of filamentUsed data retrieval for better compatibility with OctoPrint's data structure
1 parent 1573685 commit 5467376

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

octoprint_obico/print_job_tracker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ def status(self, plugin, status_only=False):
9797
data['status']['currentLayerHeight'] = self.current_layer_height # use camel-case to be consistent with the existing convention
9898

9999
# Backfill progress.filamentUsed from job.filament.tool0.length for new OctoPrint versions
100-
progress = data.get('status', {}).get('progress', {})
100+
progress = (data.get('status') or {}).get('progress') or {}
101101
if progress and 'filamentUsed' not in progress:
102-
filament_length = data.get('status', {}).get('job', {}).get('filament', {}).get('tool0', {}).get('length')
102+
filament_length = ((((data.get('status') or {}).get('job') or {}).get('filament') or {}).get('tool0') or {}).get('length')
103103
if filament_length is not None:
104104
progress['filamentUsed'] = filament_length
105105

0 commit comments

Comments
 (0)