Detect connection errors
This commit is contained in:
parent
5e25f32776
commit
7629ef1735
2 changed files with 19 additions and 8 deletions
|
|
@ -62,7 +62,7 @@ class Cragr(Browser):
|
|||
self.login()
|
||||
|
||||
def is_logged(self):
|
||||
return self.page is not None and not self.is_on_page(HomePage)
|
||||
return self.page is not None and not self.is_on_page(HomePage) and self.page.get_error() is None
|
||||
|
||||
def login(self):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -26,7 +26,17 @@ from weboob.deprecated.browser import Page, BrokenPageError
|
|||
from weboob.tools.capabilities.bank.transactions import FrenchTransaction as Transaction
|
||||
|
||||
|
||||
class HomePage(Page):
|
||||
class BasePage(Page):
|
||||
def get_error(self):
|
||||
try:
|
||||
error = self.document.xpath('//h1[@class="h1-erreur"]')[0]
|
||||
self.logger.error('Error detected: %s', error.text_content().strip())
|
||||
return error
|
||||
except IndexError:
|
||||
return None
|
||||
|
||||
|
||||
class HomePage(BasePage):
|
||||
def get_post_url(self):
|
||||
for script in self.document.xpath('//script'):
|
||||
text = script.text
|
||||
|
|
@ -40,7 +50,7 @@ class HomePage(Page):
|
|||
return None
|
||||
|
||||
|
||||
class LoginPage(Page):
|
||||
class LoginPage(BasePage):
|
||||
def login(self, password):
|
||||
imgmap = {}
|
||||
for td in self.document.xpath('//table[@id="pave-saisie-code"]/tr/td'):
|
||||
|
|
@ -59,15 +69,15 @@ class LoginPage(Page):
|
|||
return self.parser.tocleanstring(self.document.getroot())
|
||||
|
||||
|
||||
class UselessPage(Page):
|
||||
class UselessPage(BasePage):
|
||||
pass
|
||||
|
||||
|
||||
class LoginErrorPage(Page):
|
||||
class LoginErrorPage(BasePage):
|
||||
pass
|
||||
|
||||
|
||||
class _AccountsPage(Page):
|
||||
class _AccountsPage(BasePage):
|
||||
COL_LABEL = 0
|
||||
COL_ID = 2
|
||||
COL_VALUE = 4
|
||||
|
|
@ -136,7 +146,7 @@ class _AccountsPage(Page):
|
|||
return links
|
||||
|
||||
|
||||
class CardsPage(Page):
|
||||
class CardsPage(BasePage):
|
||||
def get_list(self):
|
||||
TABLE_XPATH = '//table[caption[@class="caption tdb-cartes-caption" or @class="ca-table caption"]]'
|
||||
|
||||
|
|
@ -247,7 +257,8 @@ class SavingsPage(_AccountsPage):
|
|||
COL_ID = 1
|
||||
|
||||
|
||||
class TransactionsPage(Page):
|
||||
|
||||
class TransactionsPage(BasePage):
|
||||
def get_iban_url(self):
|
||||
for link in self.document.xpath('//a[contains(text(), "IBAN")]'):
|
||||
m = re.search("\('([^']+)'", link.get('href', ''))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue