summaryrefslogtreecommitdiff
path: root/src/client.py
diff options
context:
space:
mode:
authorlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2010-02-01 14:51:52 +0000
committerlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2010-02-01 14:51:52 +0000
commita47b1e6fb354bbed3b4784a9ca95a10bcdad0fc8 (patch)
tree6cbdade38e4e56732f281acf15220a6e4fd57143 /src/client.py
parentfb783bdc53bbdfd492b30e2b08a34bb566e8c39d (diff)
downloadpoezio-a47b1e6fb354bbed3b4784a9ca95a10bcdad0fc8.tar.gz
poezio-a47b1e6fb354bbed3b4784a9ca95a10bcdad0fc8.tar.bz2
poezio-a47b1e6fb354bbed3b4784a9ca95a10bcdad0fc8.tar.xz
poezio-a47b1e6fb354bbed3b4784a9ca95a10bcdad0fc8.zip
nouvelle gestion des traceback, beaucoup mieux pour debuguer
Diffstat (limited to 'src/client.py')
-rw-r--r--src/client.py26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/client.py b/src/client.py
index a4249f9e..ddb2e901 100644
--- a/src/client.py
+++ b/src/client.py
@@ -24,14 +24,28 @@ from config import config
from handler import Handler
from gui import Gui
from curses import wrapper, initscr
+import curses
-sys.stderr = open('log', 'w')
+import signal
+signal.signal(signal.SIGINT, signal.SIG_IGN)
-if len(sys.argv) == 1: # not debug, so hide any error message and disable C-c
- import signal
- signal.signal(signal.SIGINT, signal.SIG_IGN)
- sys.stderr = open('/dev/null', 'w')
- sys.stdout = open('/dev/null', 'w')
+# disable any printout (this would mess the display)
+stderr = sys.stderr
+sys.stderr = open('/dev/null', 'w')
+sys.stdout = open('/dev/null', 'w')
+
+import traceback
+def exception_handler(type_, value, tb):
+ """
+ on any traceback: exit ncurses and print the traceback
+ then exit the program
+ """
+ curses.echo()
+ curses.endwin()
+ traceback.print_exception(type_, value, tb, None, stderr)
+ sys.exit()
+
+sys.excepthook = exception_handler
class Client(object):
"""