Commit 095ad4ae authored by Vincent Paredes's avatar Vincent Paredes Committed by Romain Bignon

new login image for virtkeyboard

parent f0e66f1e
......@@ -20,8 +20,11 @@
import hashlib
import re
import lxml.etree as etree
from import BasePage, BrowserUnavailable
from import MappedVirtKeyboard
from import VirtKeyboard
__all__ = ['LoginPage', 'BadLoginPage', 'AccountDesactivate', 'Initident', 'CheckPassword', 'repositionnerCheminCourant', 'UnavailablePage']
......@@ -36,7 +39,7 @@ class UnavailablePage(BasePage):
def on_loaded(self):
raise BrowserUnavailable()
class VirtKeyboard(MappedVirtKeyboard):
class Keyboard(VirtKeyboard):
......@@ -52,14 +55,26 @@ class VirtKeyboard(MappedVirtKeyboard):
color=(0xff, 0xff, 0xff)
def __init__(self, page):
img = page.document.find("//img[@usemap='#map']")
img_file = page.browser.openurl(img.attrib['src'])
MappedVirtKeyboard.__init__(self, img_file, page.document, img, self.color, map_attr='id')
img_url ='background:url\((.*?)\)',etree.tostring(page.document)).group(1)
coords = {}
size = 252
x, y, width, height = (0, 0, size/4, size/4)
for i,a in enumerate(page.document.xpath('//div[@id="imageclavier"]//button')):
code = '%02d' % i
coords[code] = (x+8, y+8, x+height-8, y+height-8)
if (x + width + 1) >= size:
y += height
x = 0
x += width
VirtKeyboard.__init__(self, page.browser.openurl(img_url), coords, self.color)
self.check_symbols(self.symbols, page.browser.responses_dirname)
def get_symbol_code(self,md5sum):
code = MappedVirtKeyboard.get_symbol_code(self,md5sum)
code = VirtKeyboard.get_symbol_code(self,md5sum)
return '%02d' % int(code.split('_')[-1])
def get_string_code(self,string):
......@@ -70,11 +85,11 @@ class VirtKeyboard(MappedVirtKeyboard):
def get_symbol_coords(self, (x1, y1, x2, y2)):
# strip borders
return MappedVirtKeyboard.get_symbol_coords(self, (x1+3, y1+3, x2-3, y2-3))
return VirtKeyboard.get_symbol_coords(self, (x1+3, y1+3, x2-3, y2-3))
class LoginPage(BasePage):
def login(self, login, pwd):
vk = VirtKeyboard(self)
vk = Keyboard(self)
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