summaryrefslogtreecommitdiff
path: root/src/poezio.py
diff options
context:
space:
mode:
authorlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2010-06-13 18:58:39 +0000
committerlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2010-06-13 18:58:39 +0000
commit08c81a900c3301088659b9c08246239bf3dd2bea (patch)
tree1410b143c326bfbb8a72de8c3aab962bfeaa2d7d /src/poezio.py
parent9c492501f4406e74ba989e5519f40d723f52873d (diff)
downloadpoezio-08c81a900c3301088659b9c08246239bf3dd2bea.tar.gz
poezio-08c81a900c3301088659b9c08246239bf3dd2bea.tar.bz2
poezio-08c81a900c3301088659b9c08246239bf3dd2bea.tar.xz
poezio-08c81a900c3301088659b9c08246239bf3dd2bea.zip
enable the tracebacks
Diffstat (limited to 'src/poezio.py')
-rw-r--r--src/poezio.py41
1 files changed, 33 insertions, 8 deletions
diff --git a/src/poezio.py b/src/poezio.py
index e2e6fd99..501ccfd2 100644
--- a/src/poezio.py
+++ b/src/poezio.py
@@ -21,25 +21,50 @@
Starting point of poezio. Launches both the Connection and Gui
"""
import sys
+import traceback
+import curses
-# disable any printout (this would mess the display)
-if len(sys.argv) == 2:
- sys.stderr = open('errors', 'a')
-else:
- sys.stderr = open('/dev/null', 'a')
+class MyStdErr(object):
+ def __init__(self, fd):
+ """
+ Change sys.stderr to something like /dev/null
+ to disable any printout on the screen that would
+ mess everything
+ """
+ self.old_stderr = sys.stderr
+ sys.stderr = fd
+ def restaure(self):
+ """
+ Restaure the good ol' sys.stderr, because we need
+ it in order to print the tracebacks
+ """
+ sys.stderr = self.old_stderr
+
+my_stderr = MyStdErr(open('/dev/null', 'a'))
+
+def exception_handler(type_, value, trace):
+ """
+ on any traceback: exit ncurses and print the traceback
+ then exit the program
+ """
+ global my_stderr
+ my_stderr.restaure()
+ curses.endwin()
+ curses.echo()
+ traceback.print_exception(type_, value, trace, None, sys.stderr)
+ sys.exit(2)
+
+sys.excepthook = exception_handler
from connection import Connection
from multiuserchat import MultiUserChat
from config import config
from gui import Gui
from curses import initscr
-from common import exception_handler
import signal
signal.signal(signal.SIGINT, signal.SIG_IGN) # ignore ctrl-c
-sys.excepthook = exception_handler
-
def main():
"""
main function