Added warning when failing to connect to osTicket

* Fixes issue #34
This commit is contained in:
2Shirt 2018-12-28 18:01:10 -07:00
parent 73bd9bb009
commit dfe009c413
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C

View file

@ -30,7 +30,7 @@ class osTicket():
self.tests_disk = tests_disk
self.tunnel_proc = None
def connect(self):
def connect(self, silent=True):
"""Establish connection to osTicket via a SSH tunnel."""
cmd = [
'ssh', '-N',
@ -74,6 +74,11 @@ class osTicket():
if self.db_cursor is None:
self.disabled = True
self.tunnel_proc.kill()
if not silent:
print_warning('Failed to connect to osTicket')
print_standard('Integration disabled for this session')
print_standard(' ')
pause()
def convert_report(self, name, test):
"""Convert report into an osTicket friendly format, returns list."""
@ -354,7 +359,7 @@ class osTicket():
def get_ticket_number(self):
"""Get ticket number and confirm with name from osTicket DB."""
ticket_number = None
self.connect()
self.connect(silent=False)
# Bail if disabled
if self.disabled:
@ -369,6 +374,7 @@ class osTicket():
# No ticket ID entered
if re.match(r'^\s*$', _input):
if ask('Disable osTicket integration for this run?'):
self.disabled = True
break
# Invalid ID entered