diff options
author | louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13> | 2010-03-24 16:44:55 +0000 |
---|---|---|
committer | louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13> | 2010-03-24 16:44:55 +0000 |
commit | 899a33ae477df3dec4541cb86d65783677d37211 (patch) | |
tree | 270ae36f397c6fef2cdc281290df86b71a305c65 /src/connection.py | |
parent | 42fbbddbd4e751e7d13c76cff46b1bc66fc790d9 (diff) | |
download | poezio-899a33ae477df3dec4541cb86d65783677d37211.tar.gz poezio-899a33ae477df3dec4541cb86d65783677d37211.tar.bz2 poezio-899a33ae477df3dec4541cb86d65783677d37211.tar.xz poezio-899a33ae477df3dec4541cb86d65783677d37211.zip |
fixed #1235 (affiche un message si la connexion echoue)
Diffstat (limited to 'src/connection.py')
-rw-r--r-- | src/connection.py | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/connection.py b/src/connection.py index 9b047da9..c514d964 100644 --- a/src/connection.py +++ b/src/connection.py @@ -17,6 +17,16 @@ # You should have received a copy of the GNU General Public License # along with Poezio. If not, see <http://www.gnu.org/licenses/>. +from gettext import (bindtextdomain, textdomain, bind_textdomain_codeset, + gettext as _) + + +bindtextdomain('poezio') +textdomain('poezio') +bind_textdomain_codeset('poezio', 'utf-8') +import locale +locale.setlocale(locale.LC_ALL, '') + import sys import xmpp @@ -50,10 +60,10 @@ class Connection(threading.Thread): """ sys.excepthook = exception_handler if not self.connect_to_server(self.server, self.port): - logger.error('Could not connect to server') + self.handler.emit('error', msg='Could not connect to server') sys.exit(-1) if not self.authenticate(): - logger.error('Could not authenticate to server') + self.handler.emit('error', msg='Could not authenticate to server') sys.exit(-1) self.client.sendInitPresence(requestRoster=0) self.online = 1 # 2 when confirmation of auth is received @@ -74,7 +84,12 @@ class Connection(threading.Thread): def authenticate(self, anon=True): if anon: - return self.client.auth(None, "", self.resource) + try: + self.client.auth(None, "", self.resource) + return True + except TypeError: + self.handler.emit('error', msg=_('Error: Could not authenticate. Please make sure the server you chose (%s) supports anonymous authentication' % (config.get('server', '')))) # TODO msg + return None else: log.error('Non-anonymous connections not handled currently') return None |