Skip to content

Commit

Permalink
[#18] Handle missing progress and job times
Browse files Browse the repository at this point in the history
  • Loading branch information
ra100 authored and tg44 committed Oct 4, 2020
1 parent 1224c58 commit 461d2f6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions octoprint_prometheus_exporter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,12 @@ def gcodephase_hook(self, comm_instance, phase, cmd, cmd_type, gcode, subcode=No
if self.print_progress_label != '':
data = self._printer.get_current_data()
#self._logger.info(data)
self.print_time_elapsed.labels(self.print_progress_label).set(data['progress']['printTime'])
self.print_time_est.labels(self.print_progress_label).set(data['job']['estimatedPrintTime'])
self.print_time_left_est.labels(self.print_progress_label).set(data['progress']['printTimeLeft'])
if data['progress']['printTime'] is not None:
self.print_time_elapsed.labels(self.print_progress_label).set(data['progress']['printTime'])
if data['progress']['printTimeLeft'] is not None:
self.print_time_left_est.labels(self.print_progress_label).set(data['progress']['printTimeLeft'])
if data['job']['estimatedPrintTime'] is not None:
self.print_time_est.labels(self.print_progress_label).set(data['job']['estimatedPrintTime'])

return None # no change

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
plugin_name = "OctoPrint-Prometheus-Exporter"

# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
plugin_version = "0.1.5"
plugin_version = "0.1.6"

# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
# module
Expand Down

0 comments on commit 461d2f6

Please sign in to comment.