From 8677d8b18302a3dcebb50ad73de5c00db92cc5dc Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Sun, 22 Jul 2012 21:12:51 +0200 Subject: [PATCH] raise a BrowserIncorrectPassword exception when handling a 401 --- weboob/tools/browser/browser.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/weboob/tools/browser/browser.py b/weboob/tools/browser/browser.py index 83e28613..255a93a5 100644 --- a/weboob/tools/browser/browser.py +++ b/weboob/tools/browser/browser.py @@ -260,11 +260,15 @@ class StandardBrowser(mechanize.Browser): return self._openurl(*args, **kwargs) def get_exception(self, e): - if (isinstance(e, urllib2.HTTPError) and hasattr(e, 'getcode') and e.getcode() in (404, 403)) or \ - isinstance(e, mechanize.BrowserStateError): + if isinstance(e, urllib2.HTTPError) and hasattr(e, 'getcode'): + if e.getcode() in (404, 403): + return BrowserHTTPNotFound + if e.getcode() == 401: + return BrowserIncorrectPassword + elif isinstance(e, mechanize.BrowserStateError): return BrowserHTTPNotFound - else: - return BrowserHTTPError + + return BrowserHTTPError def readurl(self, url, *args, **kwargs): """