parent
8be59c2c13
commit
85212fb171
1 changed files with 24 additions and 15 deletions
|
|
@ -18,6 +18,11 @@ REGEX_TEMPS = re.compile(r'^\s*(.*?)\s+(idle:)(.*)$')
|
||||||
REGEX_SENSOR = re.compile(r'^(.*?)(\s*)$')
|
REGEX_SENSOR = re.compile(r'^(.*?)(\s*)$')
|
||||||
|
|
||||||
|
|
||||||
|
# Error Classes
|
||||||
|
class osTicketConnectionError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
# Classes
|
# Classes
|
||||||
class osTicket():
|
class osTicket():
|
||||||
"""Class to track osTicket data and functions."""
|
"""Class to track osTicket data and functions."""
|
||||||
|
|
@ -70,15 +75,9 @@ class osTicket():
|
||||||
# Connection established
|
# Connection established
|
||||||
break
|
break
|
||||||
|
|
||||||
# Disable if necessary
|
# Raise exception unless silenced
|
||||||
if self.db_cursor is None:
|
if self.db_cursor is None and not silent:
|
||||||
self.disabled = True
|
raise osTicketConnectionError('Failed to connect to osTicket.')
|
||||||
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):
|
def convert_report(self, name, test):
|
||||||
"""Convert report into an osTicket friendly format, returns list."""
|
"""Convert report into an osTicket friendly format, returns list."""
|
||||||
|
|
@ -347,7 +346,7 @@ class osTicket():
|
||||||
def get_flag(self, ticket_id, flag_name):
|
def get_flag(self, ticket_id, flag_name):
|
||||||
"""Get flag in osTicket."""
|
"""Get flag in osTicket."""
|
||||||
flag_value = None
|
flag_value = None
|
||||||
self.connect(silent=True)
|
self.connect()
|
||||||
|
|
||||||
# Bail if disabled
|
# Bail if disabled
|
||||||
if self.disabled:
|
if self.disabled:
|
||||||
|
|
@ -395,11 +394,21 @@ class osTicket():
|
||||||
def get_ticket_number(self):
|
def get_ticket_number(self):
|
||||||
"""Get ticket number and confirm with name from osTicket DB."""
|
"""Get ticket number and confirm with name from osTicket DB."""
|
||||||
ticket_number = None
|
ticket_number = None
|
||||||
self.connect(silent=False)
|
|
||||||
|
|
||||||
# Bail if disabled
|
# Connect
|
||||||
if self.disabled:
|
while True:
|
||||||
|
try:
|
||||||
|
self.connect(silent=False)
|
||||||
|
except osTicketConnectionError:
|
||||||
|
print_warning('Failed to connect to osTicket')
|
||||||
|
if not ask('Try again?'):
|
||||||
|
print_standard('Integration disabled for this session')
|
||||||
|
self.disabled = True
|
||||||
|
self.tunnel_proc.kill()
|
||||||
return None
|
return None
|
||||||
|
else:
|
||||||
|
# Connection successful
|
||||||
|
break
|
||||||
|
|
||||||
# Main loop
|
# Main loop
|
||||||
while ticket_number is None:
|
while ticket_number is None:
|
||||||
|
|
@ -498,7 +507,7 @@ class osTicket():
|
||||||
|
|
||||||
def set_flag(self, ticket_id, flag_name, flag_value):
|
def set_flag(self, ticket_id, flag_name, flag_value):
|
||||||
"""Set flag in osTicket."""
|
"""Set flag in osTicket."""
|
||||||
self.connect(silent=True)
|
self.connect()
|
||||||
|
|
||||||
# Bail if disabled
|
# Bail if disabled
|
||||||
if self.disabled:
|
if self.disabled:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue