Added safety checks

This commit is contained in:
2Shirt 2020-01-10 17:04:13 -07:00
parent e9e19053f4
commit dcd1525c4f
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C

View file

@ -236,7 +236,15 @@ class osTicket(): # pylint: disable=invalid-name
"""Set CPU max temp in osTicket for ticket_id."""
LOG.info(f'Setting max CPU temp to {temp}')
self._connect()
# Bail if disabled
if self.disabled:
return
# Update temp
self._set_flag(FLAG_MAX_TEMP, temp)
# Done
self._disconnect()
def set_flag_failed(self, flag_name):
@ -245,6 +253,10 @@ class osTicket(): # pylint: disable=invalid-name
real_flag_name = FLAG_CPU if flag_name == 'CPU' else FLAG_DISK
self._connect()
# Bail if disabled
if self.disabled:
return
# Set flag
self._set_flag(real_flag_name, FLAG_CODES['Fail'])
@ -259,6 +271,10 @@ class osTicket(): # pylint: disable=invalid-name
real_flag_name = FLAG_CPU if flag_name == 'CPU' else FLAG_DISK
self._connect()
# Bail if disabled
if self.disabled:
return
# Bail if flag checkbox set as FAILED
if self._get_flag(real_flag_name) == str(FLAG_CODES['Fail']):
print_warning(