[weboob] [PATCH 1/1] LCL: deal with wrong login

Pierre Mazière pierre.maziere at gmail.com
Wed Mar 9 10:44:44 CET 2011


Signed-off-by: Pierre Mazière <pierre.maziere at gmail.com>
---
 weboob/backends/lcl/browser.py |    5 ++---
 weboob/backends/lcl/pages.py   |    9 +++++++--
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/weboob/backends/lcl/browser.py b/weboob/backends/lcl/browser.py
index 0b64ba2..35cca6d 100644
--- a/weboob/backends/lcl/browser.py
+++ b/weboob/backends/lcl/browser.py
@@ -56,9 +56,8 @@ class LCLBrowser(BaseBrowser):
             self.location('%s://%s/index.html' % (self.PROTOCOL, self.DOMAIN),\
                           no_login=True)
 
-        self.page.login(self.agency, self.username, self.password)
-
-        if not self.is_logged() or \
+        if not self.page.login(self.agency, self.username, self.password) or \
+           not self.is_logged() or \
            (self.is_on_page(LoginResultPage) and self.page.is_error()) :
             raise BrowserIncorrectPassword()
 
diff --git a/weboob/backends/lcl/pages.py b/weboob/backends/lcl/pages.py
index a8e4dba..2379178 100644
--- a/weboob/backends/lcl/pages.py
+++ b/weboob/backends/lcl/pages.py
@@ -19,7 +19,7 @@
 from datetime import date
 from weboob.capabilities.bank import Operation
 from weboob.capabilities.bank import Account
-from weboob.tools.browser import BasePage
+from weboob.tools.browser import BasePage, BrowserUnavailable
 
 class LoginPage(BasePage):
     def login(self, agency, login, passwd):
@@ -27,7 +27,12 @@ class LoginPage(BasePage):
         self.browser['agenceId'] = agency
         self.browser['compteId'] = login
         self.browser['CodeId'] = passwd
-        self.browser.submit()
+        try:
+            self.browser.submit()
+        except BrowserUnavailable:
+            # Login is not valid
+            return False
+        return True
 
 class LoginResultPage(BasePage):
     def is_error(self):
-- 
1.7.2.3




More information about the weboob mailing list