From 426d77147fa6f4e1d7f338114fe25dca5742f779 Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Sat, 11 Jan 2020 20:46:45 -0700 Subject: [PATCH] Disable ost if connection fails post ticket select --- scripts/wk/osticket.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/scripts/wk/osticket.py b/scripts/wk/osticket.py index e032eaa3..bfc2158c 100644 --- a/scripts/wk/osticket.py +++ b/scripts/wk/osticket.py @@ -74,9 +74,14 @@ class osTicket(): # pylint: disable=invalid-name break # Raise exception if necessary - if self.db_cursor is None and not silent: + if self.db_cursor is None: LOG.error('Failed to connect to osTicket database') - raise RuntimeError('Failed to connect to osTicket database') + if silent: + # Don't raise exceptions, just disable ost + self.disabled = True + self.errors = True + else: + raise RuntimeError('Failed to connect to osTicket database') def _disconnect(self): """Close osTicket connection.""" @@ -197,7 +202,7 @@ class osTicket(): # pylint: disable=invalid-name """Post a reply to a ticket in osTicket.""" lines = [] test_station = get_test_station_name() - self._connect() + self._connect(silent=True) self._verify_ticket_id() # Bail if disabled @@ -308,7 +313,7 @@ class osTicket(): # pylint: disable=invalid-name NOTE: This will not replace a higher temp value. """ LOG.info('Setting max CPU temp to %s', temp) - self._connect() + self._connect(silent=True) # Bail if disabled if self.disabled: @@ -331,7 +336,7 @@ class osTicket(): # pylint: disable=invalid-name """Set flag as failed in osTicket for ticket_id.""" LOG.warning('Setting osTicket %s checkbox to FAILED', flag_name) real_flag_name = FLAG_CPU if flag_name == 'CPU' else FLAG_DISK - self._connect() + self._connect(silent=True) # Bail if disabled if self.disabled: @@ -349,7 +354,7 @@ class osTicket(): # pylint: disable=invalid-name NOTE: This will not overwrite a failed status. """ real_flag_name = FLAG_CPU if flag_name == 'CPU' else FLAG_DISK - self._connect() + self._connect(silent=True) # Bail if disabled if self.disabled: