Page MenuHomePhabricator

Make captcha(-old)?.py python3 compatible
Closed, ResolvedPublic

Description

From issues on T157734 it'd be nice to try it on python3 for any performance gains...

Event Timeline

Change 337247 had a related patch set uploaded (by Reedy):
Swap print statements to python3 compatible print

https://gerrit.wikimedia.org/r/337247

That fixes one problem

The second one is, even with python3-pil installed...

This script requires the Python Imaging Library - http://www.pythonware.com/products/pil/

Needs

from PIL import Image

Patch updated and retitled

time python3 'captcha-old.py' --key 'CHANGE_THIS_SECRET!' --output '/tmp/mw-fancycaptcha-1486771866-0b4ca9' --count '100' --dirs '0' --wordlist '/home/reedy/words' --font '/usr/share/fonts/truetype/freefont/FreeMonoBoldOblique.ttf' --blacklist '/home/reedy/badwords'
Generating 100 CAPTCHA images separated in 100.0 image(s) per chunk run by 1 threads...
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.5/threading.py", line 862, in run
    self._target(*self._args, **self._kwargs)
  File "captcha-old.py", line 185, in run_in_thread
    for i in range(count):
TypeError: 'float' object cannot be interpreted as an integer

Ok, https://gerrit.wikimedia.org/r/337247 makes them now work on python3

And the thread patch also updated for similar reasons, and rebased ontop of it

Reedy triaged this task as Medium priority.

Change 337247 merged by jenkins-bot:
Make captcha python scripts python3 compatible

https://gerrit.wikimedia.org/r/337247