diff --git a/modules/barclays/browser.py b/modules/barclays/browser.py index de1338581ac0eb1b6ec9c01a9bc876773abe47b0..aee4a5c8ccd7b83cc002fb35d1ab5c0647567919 100644 --- a/modules/barclays/browser.py +++ b/modules/barclays/browser.py @@ -26,9 +26,10 @@ from weboob.exceptions import BrowserIncorrectPassword from weboob.capabilities.bank import Account from weboob.capabilities.base import NotAvailable +from weboob.tools.decorators import retry from .pages import ( - LoginPage, AccountsPage, AccountPage, MarketAccountPage, + SecretTooShort, LoginPage, AccountsPage, AccountPage, MarketAccountPage, LifeInsuranceAccountPage, CardPage, IbanPDFPage, ActionNeededPage, RevolvingAccountPage, LoanAccountPage, ) @@ -103,6 +104,7 @@ def _multiple_account_choice(self, account): accounts = [a for a in self.cache['accounts'] if a._uncleaned_id == account._uncleaned_id] return not any(a for a in accounts if a.id in self.cache['history']) + @retry(SecretTooShort, tries=4) def do_login(self): self.login.go() self.page.login(self.username, self.password) diff --git a/modules/barclays/pages.py b/modules/barclays/pages.py index ee9d849c815e27d245baf8d434ec8d185d34040e..635037bcef04a817d5765c77236cbfe6b634bf7a 100644 --- a/modules/barclays/pages.py +++ b/modules/barclays/pages.py @@ -30,11 +30,20 @@ from weboob.tools.capabilities.bank.iban import is_iban_valid from weboob.exceptions import ActionNeeded + def MyDecimal(*args, **kwargs): kwargs.update(replace_dots=True, default=NotAvailable) return CleanDecimal(*args, **kwargs) +class SecretTooShort(Exception): + # secret is a word which contains at least 8 char and website ask us to enter 2 chars of it + # char 3 and 4 or 6 and 7 + # but sometimes it ask us to enter char 9 and 10 even if secret code contains just 8 char + # maybe because user didn't enter full secret code or because website is badly coded (who knows...) + pass + + class StatefulPage(LoggedPage, HTMLPage): def get_form_for_menu(self, menu): btn = Regexp(Attr('//div[@class="menuvert"]//a[contains(., "%s")]' % (menu), 'onclick'), r"\('', '(.*?)',")(self.doc) @@ -83,6 +92,8 @@ def login_secret(self, secret): letters = '' for n in re.findall('(\d+)', label): + if int(n) > len(secret): + raise SecretTooShort() letters += secret[int(n) - 1] if ' ' in letters: