From d9ab1730b416ecd1dbb21994031b5294e421968c Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Wed, 26 Dec 2018 20:44:20 -0700 Subject: [PATCH] Reset tunnel_proc to None on full disconnect --- .bin/Scripts/functions/osticket.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.bin/Scripts/functions/osticket.py b/.bin/Scripts/functions/osticket.py index 3578bed6..895c6130 100644 --- a/.bin/Scripts/functions/osticket.py +++ b/.bin/Scripts/functions/osticket.py @@ -139,7 +139,7 @@ class osTicket(): # Done return out_report - def disconnect(self, reset_errors=False): + def disconnect(self, full=False): """Close osTicket connection.""" try: self.db_cursor.close() @@ -148,10 +148,24 @@ class osTicket(): # Ignore errors since vars will be reset below pass + # Reset errors + if full: + self.errors = False + # Reset vars self.db_cursor = None self.db_connection = None + # Close tunnel + if full: + try: + self.tunnel_proc.kill() + self.tunnel_proc.wait(timeout=2) + except (AttributeError, subprocess.TimeoutExpired): + # Ignore and continue + pass + self.tunnel_proc = None + def generate_report(self, dev, ticket_id): """Generate device report for osTicket, returns list.""" report = []