diff --git a/modules/ovh/browser.py b/modules/ovh/browser.py index a02ce883562605a7a9368e35bd7dd9da5e2ac8ab..3233a7c2e05e952d0c5af344e52ac179c8ec2a14 100644 --- a/modules/ovh/browser.py +++ b/modules/ovh/browser.py @@ -16,6 +16,9 @@ # # You should have received a copy of the GNU Lesser General Public License # along with this weboob module. If not, see . + +from __future__ import unicode_literals + import time from requests.exceptions import HTTPError, TooManyRedirects from datetime import datetime, timedelta @@ -30,8 +33,11 @@ class OvhBrowser(LoginBrowser, StatesMixin): BASEURL = 'https://www.ovh.com' - login = URL(r'/auth/', - r'/manager/web/', LoginPage) + login = URL( + r'/auth/', + r'/manager/web/', + LoginPage, + ) profile = URL(r'/engine/api/me', ProfilePage) documents = URL(r'/engine/2api/sws/billing/bills\?count=0&date=(?P.*)&dateTo=(?P.*)&offset=0', BillsPage) @@ -66,8 +72,7 @@ def do_login(self): if not self.page.is_logged(): raise BrowserIncorrectPassword("Login / Password or authentication pin_code incorrect") - else: - return + return self.login.go() @@ -89,9 +94,13 @@ def do_login(self): @need_login def get_subscription_list(self): - return self.profile.stay_or_go().get_subscriptions() + self.profile.stay_or_go() + return self.page.get_subscriptions() @need_login def iter_documents(self, subscription): - return self.documents.stay_or_go(fromDate=(datetime.now() - timedelta(days=2*365)).strftime("%Y-%m-%dT00:00:00Z"), - toDate=time.strftime("%Y-%m-%dT%H:%M:%S.999Z")).get_documents(subid=subscription.id) + self.documents.stay_or_go( + fromDate=(datetime.now() - timedelta(days=2 * 365)).strftime("%Y-%m-%dT00:00:00Z"), + toDate=time.strftime("%Y-%m-%dT%H:%M:%S.999Z"), + ) + return self.page.get_documents(subid=subscription.id) diff --git a/modules/ovh/module.py b/modules/ovh/module.py index 9404059f208eea7ea9417d103fd3b56bb3c39bf8..0cb3caf30715d188f32079300ea5ac69006f90b2 100644 --- a/modules/ovh/module.py +++ b/modules/ovh/module.py @@ -37,9 +37,11 @@ class OvhModule(Module, CapDocument): EMAIL = 'vparedes@budget-insight.com' LICENSE = 'LGPLv3+' VERSION = '1.6' - CONFIG = BackendConfig(Value('login', label='Account ID'), - ValueBackendPassword('password', label='Password'), - Value('pin_code', label='Code PIN / Email', required=False, default='')) + CONFIG = BackendConfig( + ValueBackendPassword('login', label='Account ID'), + ValueBackendPassword('password', label='Password'), + Value('pin_code', label='Code PIN / Email', required=False, default=''), + ) BROWSER = OvhBrowser diff --git a/modules/ovh/pages.py b/modules/ovh/pages.py index fc598ea40428cc4611a17011813cef85c9f56f3c..aed8e5a8f7b76b39acb2c93bd9876045efeda15c 100644 --- a/modules/ovh/pages.py +++ b/modules/ovh/pages.py @@ -48,7 +48,7 @@ def get_error_message(self): return CleanText('//form[@class="pagination-centered"]/div[@class="error"]')(self.doc) # There is 2 double auth method - # One activated by the user, that we don't handle, + # One activated by the user, that we don't handle, # The other, spawning sometimes at first login, that we can handle. def check_user_double_auth(self):