From 794e506432da37f01732978c1c03acc1b538a3ab Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Thu, 7 May 2015 13:36:23 +0200 Subject: [PATCH] correctly handle expired sessions --- modules/cmso/web/pages.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/modules/cmso/web/pages.py b/modules/cmso/web/pages.py index fe4190e1..189e0b02 100644 --- a/modules/cmso/web/pages.py +++ b/modules/cmso/web/pages.py @@ -20,7 +20,7 @@ import datetime -from weboob.browser.pages import HTMLPage, LoggedPage, pagination +from weboob.browser.pages import HTMLPage, pagination from weboob.browser.elements import ListElement, ItemElement, method from weboob.browser.filters.standard import CleanText, CleanDecimal, Regexp, DateGuesser, Env from weboob.browser.filters.html import Link @@ -41,11 +41,19 @@ class LoginPage(HTMLPage): form.submit() +class CMSOPage(HTMLPage): + @property + def logged(self): + if len(self.doc.xpath('//b[text()="Session interrompue"]')) > 0: + return False + return True + + class CmsoListElement(ListElement): item_xpath = '//table[@class="Tb" and tr[1][@class="LnTit"]]/tr[@class="LnA" or @class="LnB"]' -class AccountsPage(LoggedPage, HTMLPage): +class AccountsPage(CMSOPage): @method class iter_accounts(CmsoListElement): class item(ItemElement): @@ -69,7 +77,7 @@ class CmsoTransactionElement(ItemElement): return len(self.el) >= 5 and not self.el.get('id', '').startswith('libelleLong') -class HistoryPage(LoggedPage, HTMLPage): +class HistoryPage(CMSOPage): def iter_history(self, *args, **kwargs): if self.doc.xpath('//a[@href="1-situationGlobaleProfessionnel.act"]'): return self.iter_history_rest_page(*args, **kwargs)