Commit 3a9d0b88 authored by sinopsysHK's avatar sinopsysHK Committed by Laurent Bachelier

[hsbchk] Cleanup

- Remove debugging tweaks (log.debug, extra overrides,...)
- Fix lint complains
- Published as a python3 compatible module
parent 5b187f22
Pipeline #2766 failed with stages
in 1 minute and 27 seconds
......@@ -103,7 +103,6 @@ class HSBCHK(StatesMixin, SubSeleniumMixin, PagesBrowser):
def do_login(self):
self.auth_token = None
self.logger.debug("currrent state is Logged:%s", self.logged)
super(HSBCHK, self).do_login()
self.auth_token = self.session.cookies.get('SYNC_TOKEN')
self.logged = True
......
......@@ -60,7 +60,7 @@ class HSBCHKModule(Module, CapBank):
yield tr
def iter_investment(self, account):
raise NotImplemented
raise NotImplementedError
def iter_coming(self, account):
# No coming entries on HSBC HK
......
......@@ -21,8 +21,6 @@ from __future__ import unicode_literals
import re
from decimal import Decimal
import requests
import json
from weboob.browser.elements import DictElement, ItemElement, method
from weboob.browser.filters.json import Dict
......@@ -125,15 +123,10 @@ class JsonAccSum(LoggedPage, JsonBasePage):
res = Account.from_dict(self.get_acc_dict(subacc))
if subacc.get('hasAcctDetails'):
yield res
else:
self.logger.debug("skip account with no history: %s", res)
elif acc_prod == "CC":
self.logger.debug("acc: %s", str(acc))
res = Account.from_dict(self.get_acc_dict(acc))
if acc.get('hasAcctDetails'):
yield res
else:
self.logger.debug("skip account with no history: %s", res)
else:
self.logger.error("Unknown account product code [%s]", acc_prod)
......@@ -146,10 +139,6 @@ class JsonAccHist(LoggedPage, JsonBasePage):
item_xpath = "txnSumm"
def next_page(self):
self.logger.debug(
"paging (%s): %s",
Dict('responsePagingInfo/moreRecords', default='N')(self.page.doc),
self.page.doc.get('responsePagingInfo'))
if Dict('responsePagingInfo/moreRecords', default='N')(self.page.doc) == 'Y':
self.logger.info("more values are available")
"""
......
......@@ -19,15 +19,6 @@
from __future__ import unicode_literals
import os
try:
from selenium import webdriver
except ImportError:
raise ImportError('Please install python-selenium')
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.common.proxy import Proxy, ProxyType
from selenium.common.exceptions import (
TimeoutException
)
......@@ -35,7 +26,7 @@ from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from weboob.exceptions import BrowserIncorrectPassword, BrowserUnavailable, BrowserHTTPError
from weboob.browser.selenium import (SeleniumBrowser, DirFirefoxProfile, VisibleXPath)
from weboob.browser.selenium import (SeleniumBrowser, VisibleXPath)
from weboob.browser import URL
from .pages.login import (
......@@ -45,8 +36,6 @@ from .pages.login import (
class LoginBrowser(SeleniumBrowser):
BASEURL = 'https://www.hsbc.com.hk/'
#DRIVER = webdriver.Remote
app_gone = False
preconnection = URL(r'https://www.ebanking.hsbc.com.hk/1/2/logon?LANGTAG=en&COUNTRYTAG=US', LoginPage)
......@@ -65,59 +54,10 @@ class LoginBrowser(SeleniumBrowser):
capa['marionette'] = True
return capa
def _setup_driver(self):
proxy = Proxy()
proxy.proxy_type = ProxyType.DIRECT
if 'http' in self.proxy:
proxy.http_proxy = self.proxy['http']
if 'https' in self.proxy:
proxy.ssl_proxy = self.proxy['https']
capa = self._build_capabilities()
proxy.add_to_capabilities(capa)
options = self._build_options()
# TODO some browsers don't need headless
# TODO handle different proxy setting?
options.set_headless(self.HEADLESS)
if self.DRIVER is webdriver.Firefox:
if self.responses_dirname and not os.path.isdir(self.responses_dirname):
os.makedirs(self.responses_dirname)
options.profile = DirFirefoxProfile(self.responses_dirname)
if self.responses_dirname:
capa['profile'] = self.responses_dirname
self.driver = self.DRIVER(options=options, capabilities=capa)
elif self.DRIVER is webdriver.Chrome:
self.driver = self.DRIVER(options=options, desired_capabilities=capa)
elif self.DRIVER is webdriver.PhantomJS:
if self.responses_dirname:
if not os.path.isdir(self.responses_dirname):
os.makedirs(self.responses_dirname)
log_path = os.path.join(self.responses_dirname, 'selenium.log')
else:
log_path = NamedTemporaryFile(prefix='weboob_selenium_', suffix='.log', delete=False).name
self.driver = self.DRIVER(desired_capabilities=capa, service_log_path=log_path)
elif self.DRIVER is webdriver.Remote:
# self.HEADLESS = False
# for debugging purpose
self.driver = webdriver.Remote(
command_executor='http://<selenium host>:<selenium port>/wd/hub',
desired_capabilities=DesiredCapabilities.FIREFOX)
else:
raise NotImplementedError()
if self.WINDOW_SIZE:
self.driver.set_window_size(*self.WINDOW_SIZE)
def load_state(self, state):
return
def do_login(self):
self.logger.debug("start do_login")
self.app_gone = False
self.preconnection.go()
......
......@@ -19,7 +19,6 @@
from weboob.tools.test import BackendTest
from weboob.capabilities.bank import Account
class HSBCHKTest(BackendTest):
MODULE = 'hsbchk'
......
......@@ -82,6 +82,7 @@ gmf
googletranslate
groupamaes
hsbc
hsbchk
hybride
imdb
imgur
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment