Skip to content

Commit

Permalink
Add option to disable printer data collection
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeoLacruz committed Jan 15, 2025
1 parent fa6b905 commit 143533d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions inventree_zebra/zebra_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ class ZebraLabelPlugin(LabelPrintingMixin, SettingsMixin, InvenTreePlugin, Sched
'description': _('Additional ZPL commands sent to the printer. Use carefully!'),
'default': '~TA000~JSN^LT0^MNW^MTT^PMN^PON^PR2,2^LRN',
},
'ENABLE_PRINTER_INFO': {
'name': 'Get Printer Info',
'description': 'Collect status info from all IP printers regularly',
'default': True,
'validator': bool,
},
}

SCHEDULED_TASKS = {
Expand Down Expand Up @@ -237,9 +243,11 @@ def get_generated_file(self, **kwargs):
return self.preview_result

def ping_printer(self, *args, **kwargs):
print('--------- ping ----------')
connection = self.get_setting('CONNECTION')

printer_data = []
if not self.get_setting('ENABLE_PRINTER_INFO'):
return (printer_data)
connection = self.get_setting('CONNECTION')
if (connection == 'network'):
port = int(self.get_setting('PORT'))
all_printer = self.collect_all_ipprinter()
Expand Down Expand Up @@ -275,7 +283,6 @@ def get_all_printer_data(self, printer, port=None):
result_hs.split(',')[1]
except Exception:
printer_data = {'interface': printer, 'printer_model': f'HI:{result}, HS:{result_hs}'}
print('ping False')
return (printer_data)
try:
total_print_length = total_print_length.replace('"', '')
Expand All @@ -294,7 +301,6 @@ def get_all_printer_data(self, printer, port=None):
'head_up': head_up,
'total_print_length': total_print_length,
}
print('ping true')
return (printer_data)

# --------------------------- get_printer_data --------------------------------
Expand Down

0 comments on commit 143533d

Please sign in to comment.