Commit a5bc85ad authored by Vincent Ardisson's avatar Vincent Ardisson Committed by Romain Bignon

[boursorama] retry when par accounts seem unavailable with unexpected error

parent d0e06658
......@@ -26,7 +26,7 @@ from dateutil import parser
from weboob.browser.retry import login_method, retry_on_logout, RetryLoginBrowser
from weboob.browser.browsers import need_login, StatesMixin
from weboob.browser.url import URL
from weboob.exceptions import BrowserIncorrectPassword, BrowserHTTPNotFound
from weboob.exceptions import BrowserIncorrectPassword, BrowserHTTPNotFound, BrowserUnavailable
from weboob.browser.exceptions import LoggedOut, ClientError
from import (
Account, AccountNotFound, TransferError, TransferInvalidAmount,
......@@ -45,6 +45,7 @@ from .pages import (
CardsNumberPage, CalendarPage, HomePage, PEPPage,
TransferAccounts, TransferRecipients, TransferCharac, TransferConfirm, TransferSent,
AddRecipientPage, StatusPage, CardHistoryPage, CardCalendarPage, CurrencyListPage, CurrencyConvertPage,
......@@ -69,6 +70,7 @@ class BoursoramaBrowser(RetryLoginBrowser, StatesMixin):
'/infos-profil', ErrorPage)
login = URL('/connexion/', LoginPage)
accounts = URL('/dashboard/comptes\?_hinclude=300000', AccountsPage)
accounts_error = URL('/dashboard/comptes\?_hinclude=300000', AccountsErrorPage)
pro_accounts = URL(r'/dashboard/comptes-professionnels\?_hinclude=1', AccountsPage)
acc_tit = URL('/comptes/titulaire/(?P<webid>.*)\?_hinclude=1', AccbisPage)
acc_rep = URL('/comptes/representative/(?P<webid>.*)\?_hinclude=1', AccbisPage)
......@@ -189,13 +191,24 @@ class BoursoramaBrowser(RetryLoginBrowser, StatesMixin):
def get_accounts_list(self):
exc = None
for x in range(3):
if self.accounts_list is not None:
self.accounts_list = []
self.loans_list = []
except BrowserUnavailable as e:
self.logger.warning('par accounts seem unavailable, retrying')
exc = e
self.accounts_list = None
exc = None
# discard all unvalid card accounts (if opposed or not yet activated)
valid_card_url = []
......@@ -234,6 +247,9 @@ class BoursoramaBrowser(RetryLoginBrowser, StatesMixin):
checking, = [account for account in self.accounts_list if account.type == Account.TYPE_CHECKING and account.url in card.url]
card.parent = checking
if exc:
raise exc
return self.accounts_list
def get_account(self, id):
......@@ -1105,3 +1105,12 @@ class CurrencyConvertPage(JsonPage):
def get_rate(self):
if not 'error' in self.doc:
return round(self.doc['rate'], 4)
class AccountsErrorPage(LoggedPage, HTMLPage):
def is_here(self):
# some braindead error seems to affect many accounts until we retry
return '[E10008]' in CleanText('//div')(self.doc)
def on_load(self):
raise BrowserUnavailable()
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