diff options
author | louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13> | 2010-11-09 20:37:39 +0000 |
---|---|---|
committer | louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13> | 2010-11-09 20:37:39 +0000 |
commit | 7fd6153720746edff4af900dc9c3579d3cde6e32 (patch) | |
tree | 41a6053716e059f24a9e4b9e3b935c28dac940c3 /src/poezio.py | |
parent | df6d2fc2d3aa8b6ea396e96acddf6b695ec35197 (diff) | |
download | poezio-7fd6153720746edff4af900dc9c3579d3cde6e32.tar.gz poezio-7fd6153720746edff4af900dc9c3579d3cde6e32.tar.bz2 poezio-7fd6153720746edff4af900dc9c3579d3cde6e32.tar.xz poezio-7fd6153720746edff4af900dc9c3579d3cde6e32.zip |
fix some little issues. Rename gui to core, use logging lib instead of the custom debug option. Add a -d option
Diffstat (limited to 'src/poezio.py')
-rw-r--r-- | src/poezio.py | 54 |
1 files changed, 32 insertions, 22 deletions
diff --git a/src/poezio.py b/src/poezio.py index a46381f9..03b6d3e6 100644 --- a/src/poezio.py +++ b/src/poezio.py @@ -21,14 +21,32 @@ Starting point of poezio. Launches both the Connection and Gui """ import os -# chdir in the source directory, to import the modules -# also, no need to use a sh script to "cd" in this directoy -# before launching poezio. -os.chdir(os.path.dirname(os.path.abspath(__file__))) - import curses import sys import traceback +import threading + +sys.path.append(os.path.dirname(os.path.abspath(__file__))) + +def installThreadExcepthook(): + """ + Workaround for sys.excepthook thread bug + See http://bugs.python.org/issue1230540 + Python, you made me sad :( + """ + init_old = threading.Thread.__init__ + def init(self, *args, **kwargs): + init_old(self, *args, **kwargs) + run_old = self.run + def run_with_except_hook(*args, **kw): + try: + run_old(*args, **kw) + except (KeyboardInterrupt, SystemExit): + raise + except: + sys.excepthook(*sys.exc_info()) + self.run = run_with_except_hook + threading.Thread.__init__ = init class MyStdErr(object): def __init__(self, fd): @@ -67,23 +85,15 @@ def exception_handler(type_, value, trace): # sys.excepthook = exception_handler import signal +import logging -from connection import Connection -from config import config -from gui import Gui - -signal.signal(signal.SIGINT, signal.SIG_IGN) # ignore ctrl-c - -def main(): - """ - The main function consist of the Connection initialization - then the gui (ncurses) init, connection handlers and then the - connection is "started" - """ - xmpp = Connection() # Connection init - gui = Gui(xmpp) # Gui init. - xmpp.start() # Connect to remote server - gui.main_loop() # Refresh the screen, wait for user events etc +from connection import connection +from config import config, options +from core import core if __name__ == '__main__': - main() + signal.signal(signal.SIGINT, signal.SIG_IGN) # ignore ctrl-c + if options.debug: + logging.basicConfig(filename=options.debug,level=logging.DEBUG) + connection.start() # Connect to remote server + core.main_loop() # Refresh the screen, wait for user events etc |