From e301bff2c2356bcaf3a3b38da1e6a0314be65c8d Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Sat, 11 Jan 2020 20:43:27 -0700 Subject: [PATCH] Avoid replacing higher temps in osTicket --- scripts/wk/osticket.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/wk/osticket.py b/scripts/wk/osticket.py index 2a560db6..e032eaa3 100644 --- a/scripts/wk/osticket.py +++ b/scripts/wk/osticket.py @@ -303,7 +303,10 @@ class osTicket(): # pylint: disable=invalid-name self._disconnect() def set_cpu_max_temp(self, temp): - """Set CPU max temp in osTicket for ticket_id.""" + """Set CPU max temp in osTicket for ticket_id. + + NOTE: This will not replace a higher temp value. + """ LOG.info('Setting max CPU temp to %s', temp) self._connect() @@ -311,6 +314,13 @@ class osTicket(): # pylint: disable=invalid-name if self.disabled: return + # Compare to current temp + current_temp = self._get_flag(FLAG_MAX_TEMP) + if str(current_temp).isnumeric() and int(current_temp) > temp: + std.print_warning('Not replacing higher temp in osTicket') + self._disconnect() + return + # Update temp self._set_flag(FLAG_MAX_TEMP, temp) @@ -350,6 +360,7 @@ class osTicket(): # pylint: disable=invalid-name std.print_warning( f'Not replacing osTicket {flag_name} checkbox FAILED value', ) + self._disconnect() return # Current value != to FAILED, updating checkbox