From 85ad345d7f69b7572b4a93727fcc51b149746b5b Mon Sep 17 00:00:00 2001 From: Christophe Francois Date: Tue, 30 Jun 2020 18:02:22 +0200 Subject: [PATCH] [spirica] Raise BrowserUnavailable when the login page doesn't load The ConnectionError is raised when the call is blocked. --- modules/spirica/browser.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/modules/spirica/browser.py b/modules/spirica/browser.py index 9811b5080b..ca33f4fb07 100644 --- a/modules/spirica/browser.py +++ b/modules/spirica/browser.py @@ -21,6 +21,9 @@ from __future__ import unicode_literals +from requests import ConnectionError +from requests.exceptions import ProxyError + from weboob.browser import LoginBrowser, URL, need_login from weboob.exceptions import BrowserIncorrectPassword, BrowserUnavailable from weboob.browser.exceptions import ServerError @@ -44,7 +47,15 @@ def __init__(self, website, *args, **kwargs): self.transaction_page = None def do_login(self): - self.login.go().login(self.username, self.password) + try: + self.login.go() + except ConnectionError as e: + # The ConnectionError is raised when the call is blocked. + if isinstance(e, ProxyError): + # ProxyError inherits ConnectionError but should be raised as is. + raise e + raise BrowserUnavailable(e) + self.page.login(self.username, self.password) if self.login.is_here(): error = self.page.get_error() -- GitLab