fix unicode issues

This commit is contained in:
Romain Bignon 2010-12-01 19:29:29 +01:00
commit 7be8efbab4
3 changed files with 11 additions and 9 deletions

View file

@ -23,6 +23,7 @@ from PyQt4.QtCore import SIGNAL, Qt
from weboob.capabilities.messages import ICapMessages, ICapMessagesPost, Message from weboob.capabilities.messages import ICapMessages, ICapMessagesPost, Message
from weboob.tools.application.qt import QtDo from weboob.tools.application.qt import QtDo
from weboob.tools.misc import to_unicode
from .ui.messages_manager_ui import Ui_MessagesManager from .ui.messages_manager_ui import Ui_MessagesManager
@ -242,9 +243,9 @@ class MessagesManager(QWidget):
self.refreshThreadMessages(backend.name, self.thread.id) self.refreshThreadMessages(backend.name, self.thread.id)
def _postReply_eb(self, backend, error, backtrace): def _postReply_eb(self, backend, error, backtrace):
content = unicode(self.tr('Unable to send message:\n%s\n')) % error content = unicode(self.tr('Unable to send message:\n%s\n')) % to_unicode(error)
if logging.root.level == logging.DEBUG: if logging.root.level == logging.DEBUG:
content += '\n%s\n' % backtrace content += '\n%s\n' % to_unicode(backtrace)
QMessageBox.critical(self, self.tr('Error while posting reply'), QMessageBox.critical(self, self.tr('Error while posting reply'),
content, QMessageBox.Ok) content, QMessageBox.Ok)
self.ui.backendsList.setEnabled(True) self.ui.backendsList.setEnabled(True)

View file

@ -23,6 +23,7 @@ from PyQt4.QtGui import QWidget, QListWidgetItem, QImage, QIcon, QPixmap, \
from PyQt4.QtCore import SIGNAL, Qt from PyQt4.QtCore import SIGNAL, Qt
from weboob.tools.application.qt import QtDo, HTMLDelegate from weboob.tools.application.qt import QtDo, HTMLDelegate
from weboob.tools.misc import to_unicode
from weboob.capabilities.contact import ICapContact, Contact from weboob.capabilities.contact import ICapContact, Contact
from weboob.capabilities.chat import ICapChat from weboob.capabilities.chat import ICapChat
from weboob.capabilities.messages import ICapMessages, ICapMessagesPost, Message from weboob.capabilities.messages import ICapMessages, ICapMessagesPost, Message
@ -185,9 +186,9 @@ class ContactThread(QWidget):
self.process_reply = None self.process_reply = None
def _postReply_eb(self, backend, error, backtrace): def _postReply_eb(self, backend, error, backtrace):
content = unicode(self.tr('Unable to send message:\n%s\n')) % error content = unicode(self.tr('Unable to send message:\n%s\n')) % to_unicode(error)
if logging.root.level == logging.DEBUG: if logging.root.level == logging.DEBUG:
content += '\n%s\n' % backtrace content += '\n%s\n' % to_unicode(backtrace)
QMessageBox.critical(self, self.tr('Error while posting reply'), QMessageBox.critical(self, self.tr('Error while posting reply'),
content, QMessageBox.Ok) content, QMessageBox.Ok)
self.process_reply = None self.process_reply = None
@ -214,9 +215,8 @@ class ContactProfile(QWidget):
self.process_contact.do('fillobj', self.contact, missing_fields, backends=self.contact.backend) self.process_contact.do('fillobj', self.contact, missing_fields, backends=self.contact.backend)
def gotError(self, backend, error, backtrace): def gotError(self, backend, error, backtrace):
#self.process_contact.default_eb(backend, error, backtrace)
self.ui.frame_photo.hide() self.ui.frame_photo.hide()
self.ui.descriptionEdit.setText('<h1>Unable to show profile</h1><p>%s</p>' % error) self.ui.descriptionEdit.setText('<h1>Unable to show profile</h1><p>%s</p>' % to_unicode(error))
def gotProfile(self, backend, contact): def gotProfile(self, backend, contact):
if not backend: if not backend:
@ -504,8 +504,8 @@ class ContactsWidget(QWidget):
self.setContact(contact) self.setContact(contact)
def urlClicked_eb(self, backend, error, backtrace): def urlClicked_eb(self, backend, error, backtrace):
content = unicode(self.tr('Unable to get contact:\n%s\n')) % error content = unicode(self.tr('Unable to get contact:\n%s\n')) % to_unicode(error)
if logging.root.level == logging.DEBUG: if logging.root.level == logging.DEBUG:
content += '\n%s\n' % backtrace content += u'\n%s\n' % to_unicode(backtrace)
QMessageBox.critical(self, self.tr('Error while getting contact'), QMessageBox.critical(self, self.tr('Error while getting contact'),
content, QMessageBox.Ok) content, QMessageBox.Ok)

View file

@ -20,6 +20,7 @@ from PyQt4.QtGui import QScrollArea, QWidget, QHBoxLayout, QVBoxLayout, QFrame,
from weboob.capabilities.account import ICapAccount, StatusField from weboob.capabilities.account import ICapAccount, StatusField
from weboob.tools.application.qt import QtDo from weboob.tools.application.qt import QtDo
from weboob.tools.misc import to_unicode
class Account(QFrame): class Account(QFrame):
def __init__(self, weboob, backend, parent=None): def __init__(self, weboob, backend, parent=None):
@ -97,7 +98,7 @@ class Account(QFrame):
self.process.body += u'<b>%s</b>: %s' % (field.label, field.value) self.process.body += u'<b>%s</b>: %s' % (field.label, field.value)
def updateStats_eb(self, backend, err, backtrace): def updateStats_eb(self, backend, err, backtrace):
self.body.setText(u'<b>Unable to connect:</b> %s' % unicode(err)) self.body.setText(u'<b>Unable to connect:</b> %s' % to_unicode(err))
self.title.setText(u'<font color=#ff0000>%s</font>' % unicode(self.title.text())) self.title.setText(u'<font color=#ff0000>%s</font>' % unicode(self.title.text()))
class AccountsStatus(QScrollArea): class AccountsStatus(QScrollArea):