Commit 9acbd581 authored by Luke Macken's avatar Luke Macken

Handle exceptions in a 2.4->3.x friendly way.

parent 42dbec38
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
import sys import sys
import socket import socket
import traceback
import threading import threading
if sys.version_info[0] == 3: if sys.version_info[0] == 3:
...@@ -82,8 +83,8 @@ class ReverseConnection(threading.Thread, PyrasiteIPC): ...@@ -82,8 +83,8 @@ class ReverseConnection(threading.Thread, PyrasiteIPC):
else: else:
running = self.on_command(cmd) running = self.on_command(cmd)
except Exception as e: except:
print(str(e)) traceback.print_exc()
running = False running = False
if not running: if not running:
self.close() self.close()
...@@ -102,9 +103,9 @@ class ReversePythonConnection(ReverseConnection): ...@@ -102,9 +103,9 @@ class ReversePythonConnection(ReverseConnection):
try: try:
exec(cmd) exec(cmd)
output = buffer.getvalue() output = buffer.getvalue()
except Exception as e: except:
output = str(e) exc_type, exc_value, exc_tb = sys.exc_info()
finally: output = exc_value.message
sys.stdout = sys.__stdout__ sys.stdout = sys.__stdout__
sys.stderr = sys.__stderr__ sys.stderr = sys.__stderr__
buffer.close() buffer.close()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment