Commit 6ee2aa04 authored by Guillaume Risbourg's avatar Guillaume Risbourg Committed by Vincent A

[bp] Add retry when failing to go to market page

Sometimes when going to the market space, the website returns an
error 404 or 403. This is usually fixed the next time.

The market_login.go() request is skipped if we already landed on the
market home page after the first location.
parent 32208c6f
......@@ -22,6 +22,8 @@ from __future__ import unicode_literals
import os
from datetime import datetime, timedelta
from requests.exceptions import HTTPError
from weboob.browser import LoginBrowser, URL, need_login
from weboob.browser.browsers import StatesMixin
from weboob.browser.exceptions import ServerError
......@@ -43,7 +45,9 @@ from .pages.accounthistory import (
LifeInsuranceInvest, LifeInsuranceHistory, LifeInsuranceHistoryInv, RetirementHistory,
SavingAccountSummary, CachemireCatalogPage,
from .pages.accountlist import MarketLoginPage, UselessPage, ProfilePage, MarketCheckPage
from .pages.accountlist import (
MarketLoginPage, UselessPage, ProfilePage, MarketCheckPage, MarketHomePage,
from import RedirectPage, ProAccountsList, ProAccountHistory, DownloadRib, RibPage
from .pages.mandate import MandateAccountsList, PreMandate, PreMandateBis, MandateLife, MandateMarket
from .linebourse_browser import LinebourseBrowser
......@@ -105,6 +109,7 @@ class BPBrowser(LoginBrowser, StatesMixin):
r'/voscomptes/canalXHTML/assurance/vie/detailMouvementHermesBompard-assuranceVie.ea\?idMouvement=(\w+)', LifeInsuranceHistoryInv)
lifeinsurance_cachemire_catalog = URL(r'', CachemireCatalogPage)
market_home = URL(r'\d+/?', MarketHomePage)
market_login = URL(r'/voscomptes/canalXHTML/bourse/aiguillage/oicFormAutoPost.jsp', MarketLoginPage)
market_check = URL(r'/voscomptes/canalXHTML/bourse/aiguillage/lancerBourseEnLigne-connexionBourseEnLigne.ea', MarketCheckPage)
useless = URL(r'', UselessPage)
......@@ -387,8 +392,19 @@ class BPBrowser(LoginBrowser, StatesMixin):
def go_linebourse(self, account):
# Sometimes the redirection done from MarketLoginPage
# (to
# throws an error 404 or 403
location = retry(HTTPError, delay=5)(self.location)
# TODO Might be deprecated, check the logs after some time to
# check if this is still used.
if not self.market_home.is_here():
self.logger.debug('Landed in unexpected market page, doing self.market_login.go()')
go = retry(HTTPError, delay=5)(self.market_login.go)
......@@ -424,6 +424,10 @@ class AccountRIB(LoggedPage, RawPage):
return None
class MarketHomePage(LoggedPage, HTMLPage):
class MarketLoginPage(LoggedPage, PartialHTMLPage):
def on_load(self):
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