fix unfinite loop on fail login, and fix error message lookup
This commit is contained in:
parent
55d37401bc
commit
ce7e019e9a
2 changed files with 11 additions and 5 deletions
|
|
@ -18,7 +18,7 @@
|
|||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from weboob.deprecated.browser import Browser
|
||||
from weboob.deprecated.browser import Browser, BrowserIncorrectPassword
|
||||
|
||||
from .pages.index import IndexPage, LoginPage
|
||||
from .pages.torrents import TorrentsPage
|
||||
|
|
@ -29,7 +29,7 @@ __all__ = ['GazelleBrowser']
|
|||
|
||||
class GazelleBrowser(Browser):
|
||||
PAGES = {'https?://[^/]+/?(index.php)?': IndexPage,
|
||||
'https?://[^/]+/login.php': LoginPage,
|
||||
'https?://[^/]+/login.php.*': LoginPage,
|
||||
'https?://[^/]+/torrents.php.*': TorrentsPage,
|
||||
}
|
||||
|
||||
|
|
@ -43,6 +43,12 @@ class GazelleBrowser(Browser):
|
|||
self.location('/login.php', no_login=True)
|
||||
self.page.login(self.username, self.password)
|
||||
|
||||
# If we are not logged, the on_loaded event on LoginPage has probably
|
||||
# raised the exception, but to be sure, check here to prevent an
|
||||
# unfinite loop if we can't find the error message.
|
||||
if self.is_on_page(LoginPage):
|
||||
raise BrowserIncorrectPassword()
|
||||
|
||||
def is_logged(self):
|
||||
if not self.page or self.is_on_page(LoginPage):
|
||||
return False
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue