Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions octoprint_prometheus_exporter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,13 @@ def print_complete_callback(self):
self.print_completion_timer = None

def print_deregister_callback(self, label):
if label != '':
self.metrics.print_progress.remove(label)
self.metrics.print_time_elapsed.remove(label)
self.metrics.print_time_est.remove(label)
self.metrics.print_time_left_est.remove(label)
if label == '':
return

self.metrics.print_progress.remove(label)
self.metrics.print_time_elapsed.remove(label)
self.metrics.print_time_est.remove(label)
self.metrics.print_time_left_est.remove(label)
self.print_progress_label = ''

def slice_deregister_callback(self, label):
Expand All @@ -74,7 +76,11 @@ def print_complete(self):

self.print_completion_timer = Timer(30, self.print_complete_callback)
self.print_completion_timer.start()
Timer(30, lambda: self.print_deregister_callback(self.print_progress_label)).start()

# capture the current print_progress_label in the timer object and immediately clear it to avoid reintroducing
# the label onto the print time metrics when gcode is sent during print_deregister_callback's execution
Timer(30, self.print_deregister_callback, [self.print_progress_label]).start()
self.print_progress_label = ''

def deactivateMetricsIfOffline(self, payload):
if payload['state_id'] == 'OFFLINE':
Expand Down Expand Up @@ -208,7 +214,7 @@ def get_update_information(self):
pip="https://github.com/tg44/OctoPrint-Prometheus-Exporter/archive/{target_version}.zip"
)
)

def is_blueprint_protected(self):
# Disable global protection, use permission system.
return False
Expand Down