Commit dc8f08dd authored by Florian Duguet's avatar Florian Duguet Committed by Romain Bignon
Browse files

[barclays] fix login

sometimes asked letter of secret code are out of size
manage this behavior and retry until 4 times

Closes: 15969@sibi 29672@sibi 15968@sibi
parent 89a9f12d
......@@ -26,9 +26,10 @@
from weboob.exceptions import BrowserIncorrectPassword
from import Account
from weboob.capabilities.base import NotAvailable
from 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 in self.cache['history'])
@retry(SecretTooShort, tries=4)
def do_login(self):
self.login.go(), self.password)
......@@ -30,11 +30,20 @@
from 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...)
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:
Supports Markdown
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