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

[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.browser import LoginBrowser, URL, need_login
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 @@ class Barclays(LoginBrowser):
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)
......
......@@ -30,11 +30,20 @@ from weboob.tools.capabilities.bank.transactions import FrenchTransaction
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 @@ class LoginPage(HTMLPage):
letters = ''
for n in re.findall('(\d+)', label):
if int(n) > len(secret):
raise SecretTooShort()
letters += secret[int(n) - 1]
if ' ' in letters:
......
Markdown is supported
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