From 8cd0dff1df669720e5b7aa9098d226cdac535429 Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Thu, 30 May 2013 14:21:51 +0200 Subject: [PATCH] do not raise BrowserIncorrectPassword when the website displays an useless "urgent message" on login --- modules/cragr/web/browser.py | 19 ++++++++++--------- modules/cragr/web/pages.py | 5 ++++- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/modules/cragr/web/browser.py b/modules/cragr/web/browser.py index d5582efa..7c168f77 100644 --- a/modules/cragr/web/browser.py +++ b/modules/cragr/web/browser.py @@ -24,7 +24,7 @@ import re from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword from weboob.tools.date import LinearDateGuesser -from .pages import HomePage, LoginPage, LoginErrorPage, AccountsPage, SavingsPage, TransactionsPage +from .pages import HomePage, LoginPage, LoginErrorPage, AccountsPage, SavingsPage, TransactionsPage, UselessPage __all__ = ['Cragr'] @@ -34,13 +34,14 @@ class Cragr(BaseBrowser): PROTOCOL = 'https' ENCODING = 'ISO-8859-1' - PAGES = {'https?://[^/]+/': HomePage, - 'https?://[^/]+/stb/entreeBam': LoginPage, - 'https?://[^/]+/stb/entreeBam\?.*act=Synthcomptes': AccountsPage, - 'https?://[^/]+/stb/entreeBam\?.*act=Synthepargnes': SavingsPage, - 'https?://[^/]+/stb/.*act=Releves.*': TransactionsPage, - 'https?://[^/]+/stb/collecteNI\?.*sessionAPP=Releves.*': TransactionsPage, - 'https?://[^/]+/stb/.*/erreur/.*': LoginErrorPage, + PAGES = {'https?://[^/]+/': HomePage, + 'https?://[^/]+/stb/entreeBam': LoginPage, + 'https?://[^/]+/stb/entreeBam\?.*act=Synthcomptes': AccountsPage, + 'https?://[^/]+/stb/entreeBam\?.*act=Synthepargnes': SavingsPage, + 'https?://[^/]+/stb/.*act=Releves.*': TransactionsPage, + 'https?://[^/]+/stb/collecteNI\?.*sessionAPP=Releves.*': TransactionsPage, + 'https?://[^/]+/stb/.*/erreur/.*': LoginErrorPage, + 'https?://[^/]+/stb/entreeBam\?.*act=Messagesprioritaires': UselessPage, } class WebsiteNotSupported(Exception): @@ -107,7 +108,7 @@ class Cragr(BaseBrowser): self.location(url) - if self.is_on_page(LoginErrorPage) or not self.is_logged(): + if self.is_on_page(LoginErrorPage): raise BrowserIncorrectPassword() if not self.is_on_page(AccountsPage): diff --git a/modules/cragr/web/pages.py b/modules/cragr/web/pages.py index 0f1b0a99..d9f6efbb 100644 --- a/modules/cragr/web/pages.py +++ b/modules/cragr/web/pages.py @@ -25,7 +25,7 @@ from weboob.tools.browser import BasePage from weboob.tools.capabilities.bank.transactions import FrenchTransaction as Transaction -__all__ = ['HomePage', 'LoginPage', 'LoginErrorPage', 'AccountsPage', 'TransactionsPage'] +__all__ = ['HomePage', 'LoginPage', 'LoginErrorPage', 'AccountsPage', 'TransactionsPage', 'UselessPage'] class HomePage(BasePage): @@ -62,6 +62,9 @@ class LoginPage(BasePage): def get_result_url(self): return self.parser.tocleanstring(self.document.getroot()) +class UselessPage(BasePage): + pass + class LoginErrorPage(BasePage): pass