Commit d56303d2 authored by Damien Mat's avatar Damien Mat Committed by Vincent A

[cragr] Switch account_space only when needed

A number of iter_ functions use go_to_account_space() function in this
module. Sometimes using it with argument '0'  is enough and avoids
trying to switch space when not needed, especially when the next request
is retried up to 6 times upon response code 500. This commit extends that
use of the function to all accounts where no switch is needed. This
saves on requests number and avoids error 500 for users with only one
parent c75739b9
......@@ -187,6 +187,7 @@ class CreditAgricoleBrowser(LoginBrowser, StatesMixin):
super(CreditAgricoleBrowser, self).__init__(*args, **kwargs) = website
self.accounts_url = None
self.total_spaces = None
# Netfinca browser:
self.weboob = kwargs.pop('weboob')
......@@ -341,10 +342,11 @@ class CreditAgricoleBrowser(LoginBrowser, StatesMixin):
def iter_spaces(self):
# Determine how many spaces are present on the connection
total_spaces ='The total number of spaces on this connection is %s.', total_spaces)
for contract in range(total_spaces):
if not self.total_spaces:
# Determine how many spaces are present on the connection
self.total_spaces ='The total number of spaces on this connection is %s.', self.total_spaces)
for contract in range(self.total_spaces):
# Switch to another space
if not self.check_space_connection(contract):
......@@ -567,6 +569,13 @@ class CreditAgricoleBrowser(LoginBrowser, StatesMixin):
def go_to_account_space(self, contract):
if self.total_spaces == 1:
if not self.accounts_page.is_here():
self.logger.warning('We have been loggged out, relogin.')
# This request often returns a 500 error on this quality website
for tries in range(4):
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