Commit ef3bd4f0 authored by Benjamin Tampigny's avatar Benjamin Tampigny Committed by Vincent Ardisson

[cmso] don't crash a full iter_accounts for a market_number

For some reasons, trying to go to market history during an iter_savings
can cause a ClientError. If not handled, this exception will make the
browser try to relogin and start over the iter_accounts but the session
is actualy not lost. In this case, we juste handle it when retrieving
the market order and in the worst case we won't have this information
parent f285f973
......@@ -38,7 +38,7 @@ from weboob.browser.filters.standard import (
)
from weboob.browser.filters.json import Dict
from weboob.browser.filters.html import Attr, Link, TableCell, AbsoluteLink
from weboob.browser.exceptions import ServerError
from weboob.browser.exceptions import ServerError, ClientError
from weboob.capabilities.bank import Account, Loan, AccountOwnership
from weboob.capabilities.wealth import Investment, MarketOrder, MarketOrderDirection, MarketOrderType
from weboob.capabilities.contact import Advisor
......@@ -289,7 +289,16 @@ class AccountsPage(LoggedPage, JsonPage):
def get_market_number(self):
label = Field('label')(self)
page = self.page.browser._go_market_history()
# sometimes this call raises a ClientError. it does not really disconnect the browser
# in order to prevent a new login attempt from the browser and a reset of the iter_accounts
# we handle the exception here
try:
page = self.page.browser._go_market_history()
except ClientError as e:
if e.response.status_code == 403:
self.logger.warning("unable to retrieve market number for account with label %s", label)
return NotAvailable
raise
return page.get_account_id(label, Field('_owner')(self))
def get_lifenumber(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