fix the captcha broker (closes #461)
This commit is contained in:
parent
345b3f6161
commit
ab2a62d79d
1 changed files with 29 additions and 31 deletions
|
|
@ -50,46 +50,43 @@ class Captcha(object):
|
||||||
return s
|
return s
|
||||||
|
|
||||||
def build_tiles(self):
|
def build_tiles(self):
|
||||||
y = 5
|
y = 1
|
||||||
ty = 0
|
ty = 0
|
||||||
while y < self.ny:
|
while y < self.ny:
|
||||||
x = 6
|
x = 1
|
||||||
tx = 0
|
tx = 0
|
||||||
while x < self.nx:
|
while x < self.nx:
|
||||||
if self[x,y] == 8:
|
|
||||||
tile = self.tiles[tx][ty]
|
tile = self.tiles[tx][ty]
|
||||||
tile.valid = True
|
for j in xrange(26):
|
||||||
yy = y
|
|
||||||
while not self[x,yy] in (3,7):
|
|
||||||
l = []
|
l = []
|
||||||
tile.map.append(l)
|
tile.map.append(l)
|
||||||
xx = x
|
for i in xrange(26):
|
||||||
while not self[xx,yy] in (3,7):
|
if self[x+i,y+j] > 20:
|
||||||
l.append(self[xx,yy])
|
l.append('.')
|
||||||
xx += 1
|
tile.valid = True
|
||||||
|
else:
|
||||||
yy += 1
|
l.append(' ')
|
||||||
|
|
||||||
|
if tile.valid:
|
||||||
self.map[tile.get_num()] = tile
|
self.map[tile.get_num()] = tile
|
||||||
|
|
||||||
x += 26
|
x += 27
|
||||||
tx += 1
|
tx += 1
|
||||||
|
|
||||||
y += 25
|
y += 27
|
||||||
ty += 1
|
ty += 1
|
||||||
|
|
||||||
|
|
||||||
class Tile(object):
|
class Tile(object):
|
||||||
hash = {'b2d25ae11efaaaec6dd6a4c00f0dfc29': 1,
|
hash = {'4a6eff78f6c6f172b75bf9fd7fd36d5d': 0,
|
||||||
'600873fa288e75ca6cca092ae95bf129': 2,
|
'70019df58ec6e96d983507de86529058': 1,
|
||||||
'da24ac28930feee169adcbc9bad4acaf': 3,
|
'683a3700dbd1b9019b5ad3ca39c545d3': 2,
|
||||||
'76294dec2a3c6a7b8d9fcc7a116d1d4f': 4,
|
'998935d6f4111bd586001468a9c705a7': 3,
|
||||||
'd9531059e3834b6b8a97e29417a47dec': 5,
|
'a5cca8bf800fa505cf7ae5039b0cc73c': 4,
|
||||||
'8ba0c0cfe5e64d6b4afb1aa6f3612c1a': 6,
|
'2317a585e19c4f245cdc8acda51e4542': 5,
|
||||||
'19e0120231e7a9cf4544f96d8c388c8a': 7,
|
'956958628d014f6e6bf59d88cd254dc6': 6,
|
||||||
'83d8ad340156cb7f5c1e64454b66c773': 8,
|
'13c35a4e7bf18e95186311876e66dd95': 7,
|
||||||
'5ee8648d77eeb3e0979f6e59b2fbe66a': 9,
|
'736894876d76899a5cfecc745b095121': 8,
|
||||||
'3f3fb79bf61ebad096e05287119169df': 0
|
'ff41cd68224bece411c7fc876ab05a1d': 9
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, _id):
|
def __init__(self, _id):
|
||||||
|
|
@ -104,7 +101,7 @@ class Tile(object):
|
||||||
s = ''
|
s = ''
|
||||||
for pxls in self.map:
|
for pxls in self.map:
|
||||||
for pxl in pxls:
|
for pxl in pxls:
|
||||||
s += '%02d' % pxl
|
s += pxl
|
||||||
return hashlib.md5(s).hexdigest()
|
return hashlib.md5(s).hexdigest()
|
||||||
|
|
||||||
def get_num(self):
|
def get_num(self):
|
||||||
|
|
@ -117,5 +114,6 @@ class Tile(object):
|
||||||
def display(self):
|
def display(self):
|
||||||
for pxls in self.map:
|
for pxls in self.map:
|
||||||
for pxl in pxls:
|
for pxl in pxls:
|
||||||
sys.stdout.write('%02d' % pxl)
|
sys.stdout.write(pxl)
|
||||||
sys.stdout.write('\n')
|
sys.stdout.write('\n')
|
||||||
|
print self.checksum()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue