create weboob.tools.browser.BrowserPasswordExpired

This commit is contained in:
Romain Bignon 2012-04-21 18:22:07 +02:00
commit 5a046f00a8
6 changed files with 13 additions and 40 deletions

View file

@ -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)

View file

@ -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 <http://www.gnu.org/licenses/>.
__all__ = ['PasswordExpired']
class PasswordExpired(Exception):
pass

View file

@ -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):

View file

@ -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()

View file

@ -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']

View file

@ -65,6 +65,9 @@ class BrowserIncorrectPassword(Exception):
class BrowserBanned(BrowserIncorrectPassword):
pass
class BrowserPasswordExpired(BrowserIncorrectPassword):
pass
class BrowserUnavailable(Exception):
pass