Commit dfb52a26 authored by Romain Bignon's avatar Romain Bignon

verbose error messages in Qt applications (closes #775)

parent a94d6c99
......@@ -172,11 +172,11 @@ class RadioFranceBackend(BaseBackend, ICapRadio, ICapCollection, ICapVideo):
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:
......
......@@ -24,7 +24,6 @@ from weboob.tools.browser.decorators import id2url
from StringIO import StringIO
from time import time
import re
import urlparse
try:
import json
......
......@@ -446,6 +446,7 @@ class ConsoleApplication(BaseApplication):
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])
......
......@@ -31,6 +31,7 @@ from PyQt4.QtGui import QMainWindow, QApplication, QStyledItemDelegate, \
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 @@ class QtDo(QObject):
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 += '<br />'
ul_opened = False
for line in backtrace.split('\n'):
......@@ -184,7 +193,8 @@ class QtDo(QObject):
msg += '</li></ul>'
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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment