Commit ae823412 authored by Olivier Da Rocha's avatar Olivier Da Rocha Committed by Vincent A

[bp] handle account details page not being available

Sometimes the details page is not yet accessible for some accounts.
Prevent crashing in this case.
parent bf342691
......@@ -564,9 +564,15 @@ class BPBrowser(LoginBrowser, StatesMixin):
elif account.type == Account.TYPE_PERP:
# PERP balances must be fetched from the details page,
# otherwise we just scrape the "Rente annuelle estimée":
balance =
if balance is not None:
account.balance = balance
balance_page =
# Sometimes the balance page is not available (with the site saying the account detail will
# soon be available). In the meantime, just skip it and use the balance we already have.
if balance_page and isinstance(balance_page, SavingAccountSummary):
balance = balance_page.get_balance()
if balance is not None:
account.balance = balance
self.logger.debug('Balance page not yet available for account %r', account)
......@@ -116,6 +116,10 @@ class item_account_generic(ItemElement):
coming = 0
details_page ='url')(self))
if not
# Details page might not always be available
return NotAvailable
coming_op_link = Link(
'//a[contains(text(), "Opérations à venir")]',
......@@ -157,6 +161,10 @@ class item_account_generic(ItemElement):
return NotAvailable
details_page ='url')(self)).page
if not details_page:
# Details page might not always be available
return NotAvailable
rib_link = Link('//a[abbr[contains(text(), "RIB")]]', default=NotAvailable)(details_page.doc)
if rib_link:
response =
......@@ -516,7 +524,12 @@ class AccountRIB(LoggedPage, RawPage):
iban_regexp = r'[A-Z]{2}\d{12}[0-9A-Z]{11}\d{2}'
def get_iban(self):
m =, extract_text(
content = extract_text(
if not content:
# This can happen if there's an error on the site while rendering the PDF (no RIB is shown)
return NotAvailable
m =, content)
if m:
return unicode(
return None
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