fix backspace key, error messages not displayed, and other stuff

This commit is contained in:
louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 2010-07-20 17:25:41 +00:00
parent a63c733d69
commit bb92c63a2c
4 changed files with 37 additions and 34 deletions

View file

@ -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):

View file

@ -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

View file

@ -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,

View file

@ -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