From dfb52a26249304f40b2da8e741851923f87a6dd5 Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Sun, 5 Feb 2012 17:18:20 +0100 Subject: [PATCH] verbose error messages in Qt applications (closes #775) --- modules/radiofrance/backend.py | 6 +++--- modules/radiofrance/browser.py | 1 - weboob/tools/application/console.py | 1 + weboob/tools/application/qt/qt.py | 18 ++++++++++++++---- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/modules/radiofrance/backend.py b/modules/radiofrance/backend.py index 06297060e2..0e72c02694 100644 --- a/modules/radiofrance/backend.py +++ b/modules/radiofrance/backend.py @@ -172,11 +172,11 @@ def fill_radio(self, radio, fields): radio.current.artist = artist return radio - # avoid warning, but TODO + # TODO # http://www.franceculture.fr/recherche/key%3DYOURSEARCH%2526type%3Demission # http://www.franceinter.fr/recherche/key%3DYOURSEARCH%2526tri%3Dpertinence%2526theme%3Ddefault%2526type%3Demission - def iter_search_results(self, *args, **kwargs): - return [] + #def iter_search_results(self, *args, **kwargs): + # return [] def get_video(self, _id): with self.browser: diff --git a/modules/radiofrance/browser.py b/modules/radiofrance/browser.py index ee277188f5..6b4148db1c 100644 --- a/modules/radiofrance/browser.py +++ b/modules/radiofrance/browser.py @@ -24,7 +24,6 @@ from StringIO import StringIO from time import time import re -import urlparse try: import json diff --git a/weboob/tools/application/console.py b/weboob/tools/application/console.py index 28cb69a20a..dec745e568 100644 --- a/weboob/tools/application/console.py +++ b/weboob/tools/application/console.py @@ -446,6 +446,7 @@ def bcall_error_handler(self, backend, error, backtrace): msg = unicode(error) if not msg: msg = 'invalid login/password.' + # TODO ask to reconfigure backend print >>sys.stderr, 'Error(%s): %s' % (backend.name, msg) if self.ask('Do you want to reconfigure this backend?', default=True): self.unload_backends(names=[backend.name]) diff --git a/weboob/tools/application/qt/qt.py b/weboob/tools/application/qt/qt.py index 730f283aa1..f133b9fd84 100644 --- a/weboob/tools/application/qt/qt.py +++ b/weboob/tools/application/qt/qt.py @@ -31,6 +31,7 @@ from weboob.core.ouiboube import Weboob from weboob.core.scheduler import IScheduler +from weboob.tools.browser import BrowserUnavailable, BrowserIncorrectPassword from weboob.tools.value import ValueInt, ValueBool, ValueBackendPassword from ..base import BaseApplication @@ -164,9 +165,17 @@ def do(self, *args, **kwargs): self.process.callback_thread(self.thread_cb, self.thread_eb) def default_eb(self, backend, error, backtrace): - # TODO display a messagebox - msg = u'%s' % error - if logging.root.level == logging.DEBUG: + msg = unicode(error) + if isinstance(error, BrowserIncorrectPassword): + if not msg: + msg = 'Invalid login/password.' + elif isinstance(error, BrowserUnavailable): + if not msg: + msg = 'website is unavailable.' + elif isinstance(error, NotImplementedError): + msg = 'This feature is not supported by this backend.\n\n' \ + 'To help the maintainer of this backend implement this feature, please contact: %s <%s>' % (backend.MAINTAINER, backend.EMAIL) + elif logging.root.level == logging.DEBUG: msg += '
' ul_opened = False for line in backtrace.split('\n'): @@ -184,7 +193,8 @@ def default_eb(self, backend, error, backtrace): msg += '' print >>sys.stderr, error print >>sys.stderr, backtrace - QMessageBox.critical(None, self.tr('Error'), msg, QMessageBox.Ok) + QMessageBox.critical(None, unicode(self.tr('Error with backend %s')) % backend.name, + msg, QMessageBox.Ok) def local_cb(self, backend, data): self.cb(backend, data) -- GitLab