From adc2cbeff8a733725a2b514addea0698a4aa42a9 Mon Sep 17 00:00:00 2001 From: Romain Pesche Date: Mon, 16 Dec 2019 15:08:24 +0100 Subject: [PATCH] [bouygues] handle case where subscription detail are not available In some case, the subscription details page, where we get the information for the subscription lab is not available. We get a 401 error when getting it. In this case, we can't get the phone numbers associated to the subscriptions. We set then the subscription label to the subscription id without the phone numbers. --- modules/bouygues/browser.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/bouygues/browser.py b/modules/bouygues/browser.py index 5625fb5fd2..09dbf6126d 100644 --- a/modules/bouygues/browser.py +++ b/modules/bouygues/browser.py @@ -104,7 +104,15 @@ def iter_subscriptions(self): self.subscriptions_page.go() for sub in self.page.iter_subscriptions(): sub.subscriber = subscriber - sub.label = self.subscription_detail_page.go(id_account=sub.id, headers=self.headers).get_label() + try: + sub.label = self.subscription_detail_page.go(id_account=sub.id, headers=self.headers).get_label() + except ClientError as e: + if e.response.status_code == 403: + # Sometimes, subscription_detail_page is not available for a subscription. + # It's impossible to get the tel number associated with it and create a label with. + sub.label = sub.id + else: + raise yield sub @need_login -- GitLab