diff --git a/src/common.py b/src/common.py index 456f73e5..b71f84fc 100644 --- a/src/common.py +++ b/src/common.py @@ -33,6 +33,7 @@ """ various useful functions """ + from datetime import datetime, timedelta import base64 import os @@ -45,35 +46,6 @@ import select import errno import time -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 - """ - my_stderr.restaure() - curses.endwin() - curses.echo() - traceback.print_exception(type_, value, trace, None, sys.stderr) - sys.exit(2) - import xmpp def debug(string): diff --git a/src/connection.py b/src/connection.py index 7871c45d..8faf0125 100644 --- a/src/connection.py +++ b/src/connection.py @@ -31,7 +31,7 @@ import xmpp from config import config from logging import logger from handler import Handler -from common import jid_get_node, jid_get_domain, is_jid_the_same, exception_handler +from common import jid_get_node, jid_get_domain, is_jid_the_same class Connection(threading.Thread): """ @@ -142,6 +142,9 @@ class Connection(threading.Thread): """ fro = presence.getFrom() toj = presence.getAttr('to') + if presence.getType() == 'error': + self.error_message(presence) + return if fro == toj: # own presence self.online = 2 self.jid = toj @@ -153,9 +156,6 @@ class Connection(threading.Thread): """ if not connection: return - if presence.getType() == 'error': - self.error_message(presence) - return self.handler.emit('room-presence', stanza=presence) raise xmpp.protocol.NodeProcessed diff --git a/src/gui.py b/src/gui.py index 62c56bc8..102ccb44 100644 --- a/src/gui.py +++ b/src/gui.py @@ -104,6 +104,7 @@ class Gui(object): "KEY_BTAB": self.last_words_completion, "KEY_RESIZE": self.resize_window, "KEY_BACKSPACE": self.window.input.key_backspace, + '^?': self.window.input.key_backspace, '^J': self.execute, '\n': self.execute, '^D': self.window.input.key_dc, diff --git a/src/poezio.py b/src/poezio.py index 6a5dc435..a73924d8 100644 --- a/src/poezio.py +++ b/src/poezio.py @@ -24,10 +24,40 @@ Starting point of poezio. Launches both the Connection and Gui import sys import traceback import curses -from common import MyStdErr, exception_handler + +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 + """ + my_stderr.restaure() + curses.endwin() + curses.echo() + traceback.print_exception(type_, value, trace, None, sys.stderr) + sys.exit(2) sys.excepthook = exception_handler +import common + from connection import Connection from multiuserchat import MultiUserChat from config import config