BNPorc: switch to the new virtual keyboard tool
Signed-off-by: Pierre Mazière <pierre.maziere@gmail.com> Signed-off-by: Romain Bignon <romain@peerfuse.org>
This commit is contained in:
parent
4f7fe4f843
commit
b0141a304b
2 changed files with 88 additions and 139 deletions
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright(C) 2009-2011 Romain Bignon
|
||||
# Copyright(C) 2009-2011 Romain Bignon, Pierre Mazière
|
||||
#
|
||||
# This file is part of weboob.
|
||||
#
|
||||
|
|
@ -23,8 +23,8 @@ import urllib
|
|||
from logging import error
|
||||
|
||||
from weboob.tools.browser import BasePage, BrowserUnavailable
|
||||
from weboob.backends.bnporc.captcha import Captcha, TileError
|
||||
|
||||
from weboob.tools.virtkeyboard import VirtKeyboard,VirtKeyboardError
|
||||
import tempfile
|
||||
|
||||
__all__ = ['LoginPage', 'ConfirmPage', 'ChangePasswordPage']
|
||||
|
||||
|
|
@ -39,14 +39,45 @@ class LoginPage(BasePage):
|
|||
raise BrowserUnavailable(msg)
|
||||
|
||||
def login(self, login, password):
|
||||
img = Captcha(self.browser.openurl('/NSImgGrille'))
|
||||
symbols={'0':'9cc4789a2cb223e8f2d5e676e90264b5',
|
||||
'1':'e10b58fc085f9683052d5a63c96fc912',
|
||||
'2':'04ec647e7b3414bcc069f0c54eb55a4c',
|
||||
'3':'fde84fd9bac725db8463554448f1e469',
|
||||
'4':'2359eea8671bf112b58264bec0294f71',
|
||||
'5':'82b55b63480114f04fad8c5c4fa5673a',
|
||||
'6':'e074864faeaeabb3be3d118192cd8879',
|
||||
'7':'753468d88d4810206a6f0ab9c6ef1b16',
|
||||
'8':'9cc4789a2cb223e8f2d5e676e90264b5',
|
||||
'9':'828cf0faf86ac78e7f43208907620527'
|
||||
}
|
||||
|
||||
map=self.document.find("//map[@name='MapGril']")
|
||||
|
||||
coords={}
|
||||
for area in map.getiterator("area"):
|
||||
code=area.attrib.get("onclick")[-4:-2]
|
||||
area_coords=[]
|
||||
for coord in area.attrib.get("coords").split(","):
|
||||
area_coords.append(int(coord))
|
||||
coords[code]=tuple(area_coords)
|
||||
|
||||
try:
|
||||
img.build_tiles()
|
||||
except TileError, err:
|
||||
vk=VirtKeyboard(self.browser.openurl("/NSImgGrille"),coords,27)
|
||||
except VirtKeyboardError,err:
|
||||
error("Error: %s" % err)
|
||||
if err.tile:
|
||||
err.tile.display()
|
||||
return False
|
||||
|
||||
for s in symbols.keys():
|
||||
try:
|
||||
vk.get_symbol_code(symbols[s])
|
||||
except VirtKeyboardError:
|
||||
if self.browser.responses_dirname is None:
|
||||
self.browser.responses_dirname = \
|
||||
tempfile.mkdtemp(prefix='weboob_session_')
|
||||
vk.generate_MD5(self.browser.responses_dirname)
|
||||
error("Error: Symbol '%s' not found; all symbol hashes are available in %s" \
|
||||
% (s,self.browser.responses_dirname))
|
||||
return False
|
||||
|
||||
self.browser.select_form('logincanalnet')
|
||||
# HACK because of fucking malformed HTML, the field isn't recognized by mechanize.
|
||||
|
|
@ -54,7 +85,10 @@ class LoginPage(BasePage):
|
|||
self.browser.set_all_readonly(False)
|
||||
|
||||
self.browser['ch1'] = login
|
||||
self.browser['ch5'] = img.get_codes(password)
|
||||
passwd=''
|
||||
for c in password:
|
||||
passwd+=vk.get_symbol_code(symbols[c])
|
||||
self.browser['ch5'] = passwd
|
||||
self.browser.submit()
|
||||
|
||||
|
||||
|
|
@ -64,17 +98,53 @@ class ConfirmPage(BasePage):
|
|||
|
||||
class ChangePasswordPage(BasePage):
|
||||
def change_password(self, current, new):
|
||||
img = Captcha(self.browser.openurl('/NSImgGrille'))
|
||||
symbols={'0':'9cc4789a2cb223e8f2d5e676e90264b5',
|
||||
'1':'e10b58fc085f9683052d5a63c96fc912',
|
||||
'2':'04ec647e7b3414bcc069f0c54eb55a4c',
|
||||
'3':'fde84fd9bac725db8463554448f1e469',
|
||||
'4':'2359eea8671bf112b58264bec0294f71',
|
||||
'5':'82b55b63480114f04fad8c5c4fa5673a',
|
||||
'6':'e074864faeaeabb3be3d118192cd8879',
|
||||
'7':'753468d88d4810206a6f0ab9c6ef1b16',
|
||||
'8':'9cc4789a2cb223e8f2d5e676e90264b5',
|
||||
'9':'828cf0faf86ac78e7f43208907620527'
|
||||
}
|
||||
|
||||
map=self.document.find("//map[@name='MapGril']")
|
||||
|
||||
coords={}
|
||||
for area in map.getiterator("area"):
|
||||
code=area.attrib.get("onclick")[-4:-2]
|
||||
area_coords=[]
|
||||
for coord in area.attrib.get("coords").split(","):
|
||||
area_coords.append(int(coord))
|
||||
coords[code]=tuple(area_coords)
|
||||
|
||||
try:
|
||||
img.build_tiles()
|
||||
except TileError, err:
|
||||
error('Error: %s' % err)
|
||||
if err.tile:
|
||||
err.tile.display()
|
||||
vk=VirtKeyboard(self.browser.openurl("/NSImgGrille"),coords,27)
|
||||
except VirtKeyboardError,err:
|
||||
error("Error: %s" % err)
|
||||
return False
|
||||
|
||||
code_current = img.get_codes(current)
|
||||
code_new = img.get_codes(new)
|
||||
for s in symbols.keys():
|
||||
try:
|
||||
vk.get_symbol_code(symbols[s])
|
||||
except VirtKeyboardError:
|
||||
if self.browser.responses_dirname is None:
|
||||
self.browser.responses_dirname = \
|
||||
tempfile.mkdtemp(prefix='weboob_session_')
|
||||
vk.generate_MD5(self.browser.responses_dirname)
|
||||
error("Error: Symbol '%s' not found; all symbol hashes are available in %s" \
|
||||
% (s,self.browser.responses_dirname))
|
||||
return False
|
||||
|
||||
code_current=''
|
||||
for c in current:
|
||||
code_current+=vk.get_symbol_code(symbols[c])
|
||||
|
||||
code_new=''
|
||||
for c in new:
|
||||
code_new+=vk.get_symbol_code(symbols[c])
|
||||
|
||||
data = {'ch1': code_current,
|
||||
'ch2': code_new,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue