From 312c77629b711b88366c5a122278820e3c349c85 Mon Sep 17 00:00:00 2001 From: Alexander Hirsch Date: Mon, 3 Jun 2019 16:08:28 -0700 Subject: [PATCH] Provides debuging option for TCP stream The TCP BaseClient class has been modified to recognize an environment variable 'PYMODES_DEBUG'. When the variable is set to 'true', the stream will halt execution rather than restarting. This is for debugging purposes and does not alter the main functionality of the program. --- pyModeS/extra/tcpclient.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pyModeS/extra/tcpclient.py b/pyModeS/extra/tcpclient.py index 22539b6..adc428f 100644 --- a/pyModeS/extra/tcpclient.py +++ b/pyModeS/extra/tcpclient.py @@ -269,7 +269,16 @@ class BaseClient(Thread): time.sleep(0.001) except Exception as e: - print("Unexpected Error:", e) + + # Provides the user an option to supply the environment + # variable PYMODES_DEBUG to halt the execution + # for debugging purposes + debug_intent = os.environ.get('PYMODES_DEBUG', None) + if debug_intent.lower() == 'true': + sys.exc_info() + sys.exit() + else: + print("Unexpected Error:", e) try: sock = self.connect()