From 19df69ab9330979842b078cc5963d0a304017e6b Mon Sep 17 00:00:00 2001 From: Jerome Berthier Date: Tue, 18 Jun 2019 14:19:11 +0200 Subject: [PATCH] [caissedepargne] fix WebsiteUnavailable when fetching history for MILLEVIE PREMIUM accounts The server returns an error 500 trying to reach history of these accounts. The same problem occurs from a web browser. --- modules/caissedepargne/browser.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/modules/caissedepargne/browser.py b/modules/caissedepargne/browser.py index a6be4468c0..79e5a25116 100644 --- a/modules/caissedepargne/browser.py +++ b/modules/caissedepargne/browser.py @@ -650,8 +650,17 @@ def _get_history_invests(self, account): if self.page.is_account_inactive(account.id): self.logger.warning('Account %s %s is inactive.' % (account.label, account.id)) return [] + + # There is (currently ?) no history for MILLEVIE PREMIUM accounts if "MILLEVIE" in account.label: - self.page.go_life_insurance(account) + try: + self.page.go_life_insurance(account) + except ServerError as ex: + if ex.response.status_code == 500 and 'MILLEVIE PREMIUM' in account.label: + self.logger.info("Can not reach history page for MILLEVIE PREMIUM account") + return [] + raise + label = account.label.split()[-1] try: self.natixis_life_ins_his.go(id1=label[:3], id2=label[3:5], id3=account.id) @@ -784,7 +793,14 @@ def get_investment(self, account): self.logger.warning('Account %s %s is inactive.' % (account.label, account.id)) return if "MILLEVIE" in account.label: - self.page.go_life_insurance(account) + try: + self.page.go_life_insurance(account) + except ServerError as ex: + if ex.response.status_code == 500 and 'MILLEVIE PREMIUM' in account.label: + self.logger.info("Can not reach investment page for MILLEVIE PREMIUM account") + return + raise + label = account.label.split()[-1] self.natixis_life_ins_inv.go(id1=label[:3], id2=label[3:5], id3=account.id) for tr in self.page.get_investments(): -- GitLab