diff --git a/modules/bnporc/browser.py b/modules/bnporc/browser.py index 580482d5..ce9e7e64 100644 --- a/modules/bnporc/browser.py +++ b/modules/bnporc/browser.py @@ -22,14 +22,13 @@ import urllib from datetime import datetime from logging import warning -from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword +from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword, BrowserPasswordExpired from weboob.capabilities.bank import TransferError, Transfer from .pages import AccountsList, AccountHistory, ChangePasswordPage, \ AccountComing, AccountPrelevement, TransferPage, \ TransferConfirmPage, TransferCompletePage, \ LoginPage, ConfirmPage, InfoMessagePage, \ MessagePage, MessagesPage -from .errors import PasswordExpired __all__ = ['BNPorc'] @@ -111,7 +110,7 @@ class BNPorc(BaseBrowser): def inner(self, *args, **kwargs): try: return func(self, *args, **kwargs) - except PasswordExpired: + except BrowserPasswordExpired: if self.rotating_password is not None: warning('[%s] Your password has expired. Switching...' % self.username) self.change_password(self.rotating_password) diff --git a/modules/bnporc/errors.py b/modules/bnporc/errors.py deleted file mode 100644 index 52c807f2..00000000 --- a/modules/bnporc/errors.py +++ /dev/null @@ -1,25 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright(C) 2009-2011 Romain Bignon -# -# This file is part of weboob. -# -# weboob is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# weboob is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with weboob. If not, see . - - -__all__ = ['PasswordExpired'] - - -class PasswordExpired(Exception): - pass diff --git a/modules/bnporc/pages/accounts_list.py b/modules/bnporc/pages/accounts_list.py index 33faa476..0b8b2d1b 100644 --- a/modules/bnporc/pages/accounts_list.py +++ b/modules/bnporc/pages/accounts_list.py @@ -22,10 +22,7 @@ from decimal import Decimal from weboob.capabilities.bank import Account from weboob.capabilities.base import NotAvailable -from weboob.tools.browser import BasePage, BrokenPageError - -from ..errors import PasswordExpired - +from weboob.tools.browser import BasePage, BrokenPageError, BrowserPasswordExpired __all__ = ['AccountsList'] @@ -83,7 +80,7 @@ class AccountsList(BasePage): # of this password for img in self.document.getroot().cssselect('img[align="middle"]'): if img.attrib.get('alt', '') == 'Changez votre code secret': - raise PasswordExpired('Your password has expired') + raise BrowserPasswordExpired('Your password has expired') return l def get_execution_id(self): diff --git a/modules/bnporc/pages/transfer.py b/modules/bnporc/pages/transfer.py index df551eda..cdfdaad4 100644 --- a/modules/bnporc/pages/transfer.py +++ b/modules/bnporc/pages/transfer.py @@ -20,10 +20,9 @@ import re -from weboob.tools.browser import BasePage +from weboob.tools.browser import BasePage, BrowserPasswordExpired from weboob.tools.ordereddict import OrderedDict from weboob.capabilities.bank import TransferError -from ..errors import PasswordExpired __all__ = ['TransferPage', 'TransferConfirmPage', 'TransferCompletePage'] @@ -40,7 +39,7 @@ class TransferPage(BasePage): def on_loaded(self): for td in self.document.xpath('//td[@class="hdvon1"]'): if td.text and 'Vous avez atteint le seuil de' in td.text: - raise PasswordExpired(td.text.strip()) + raise BrowserPasswordExpired(td.text.strip()) def get_accounts(self): accounts = OrderedDict() diff --git a/weboob/tools/browser/__init__.py b/weboob/tools/browser/__init__.py index a3b0c38a..5d90ecdf 100644 --- a/weboob/tools/browser/__init__.py +++ b/weboob/tools/browser/__init__.py @@ -22,9 +22,9 @@ from weboob.tools.browser.browser import BrowserIncorrectPassword, BrowserBanned BrowserUnavailable, BrowserRetry, \ BrowserHTTPNotFound, BrowserHTTPError, \ BasePage, BaseBrowser, BrokenPageError, \ - StandardBrowser + StandardBrowser, BrowserPasswordExpired -__all__ = ['BrowserIncorrectPassword', 'BrowserBanned', 'BrowserUnavailable', 'BrowserRetry', - 'BrowserHTTPNotFound', 'BrowserHTTPError', 'BasePage', 'BaseBrowser', - 'BrokenPageError', 'StandardBrowser'] +__all__ = ['BrowserIncorrectPassword', 'BrowserPasswordExpired', 'BrowserBanned', + 'BrowserUnavailable', 'BrowserRetry', 'BrowserHTTPNotFound', 'BrowserHTTPError', + 'BasePage', 'BaseBrowser', 'BrokenPageError', 'StandardBrowser'] diff --git a/weboob/tools/browser/browser.py b/weboob/tools/browser/browser.py index c5bb002c..83e28613 100644 --- a/weboob/tools/browser/browser.py +++ b/weboob/tools/browser/browser.py @@ -65,6 +65,9 @@ class BrowserIncorrectPassword(Exception): class BrowserBanned(BrowserIncorrectPassword): pass +class BrowserPasswordExpired(BrowserIncorrectPassword): + pass + class BrowserUnavailable(Exception): pass