add handler in applications

This commit is contained in:
Romain Bignon 2012-11-10 13:24:10 +01:00
commit 47887d5560
2 changed files with 7 additions and 2 deletions

View file

@ -33,7 +33,7 @@ from weboob.capabilities.account import ICapAccount, Account, AccountRegisterErr
from weboob.core.backendscfg import BackendAlreadyExists
from weboob.core.modules import ModuleLoadError
from weboob.core.repositories import ModuleInstallError
from weboob.tools.browser import BrowserUnavailable, BrowserIncorrectPassword
from weboob.tools.browser import BrowserUnavailable, BrowserIncorrectPassword, BrowserForbidden
from weboob.tools.value import Value, ValueBool, ValueFloat, ValueInt
from weboob.tools.misc import to_unicode
@ -477,6 +477,8 @@ class ConsoleApplication(BaseApplication):
if not msg:
msg = 'website is unavailable.'
print >>sys.stderr, u'Error(%s): %s' % (backend.name, msg)
elif isinstance(error, BrowserForbidden):
print >>sys.stderr, u'Error(%s): %s' % (backend.name, msg or 'Forbidden')
elif isinstance(error, NotImplementedError):
print >>sys.stderr, u'Error(%s): this feature is not supported yet by this backend.' % backend.name
print >>sys.stderr, u' %s To help the maintainer of this backend implement this feature,' % (' ' * len(backend.name))

View file

@ -31,7 +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.browser import BrowserUnavailable, BrowserIncorrectPassword, BrowserForbidden
from weboob.tools.value import ValueInt, ValueBool, ValueBackendPassword
from weboob.tools.misc import to_unicode
from weboob.capabilities import UserError
@ -175,6 +175,9 @@ class QtDo(QObject):
elif isinstance(error, BrowserUnavailable):
if not msg:
msg = 'Website is unavailable.'
elif isinstance(error, BrowserForbidden):
if not msg:
msg = 'This action is forbidden.'
elif isinstance(error, NotImplementedError):
msg = u'This feature is not supported by this backend.\n\n' \
u'To help the maintainer of this backend implement this feature, please contact: %s <%s>' % (backend.MAINTAINER, backend.EMAIL)