freeipa / freeipa-community-portal

[ABANDONED] FreeIPA Community Portal extension
GNU General Public License v3.0
4 stars 6 forks source link

python-pillow cannot open font resource #23

Closed frasertweedale closed 8 years ago

frasertweedale commented 8 years ago

Visiting /user results in a 500 Internal Server Error. It seems Pillow cannot open a font file.

I guess something is missing from the deploy guide, or some initialisation is not being performed by the program.

This occurs with Pillow 2.8.2 from Fedora repos as well as 2.9 from PyPI.

Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/cherrypy/_cprequest.py", line 670, in respond
    response.body = self.handler()
  File "/usr/lib/python2.7/site-packages/cherrypy/lib/encoding.py", line 217, in __call__
    self.body = self.oldhandler(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/cherrypy/_cpdispatch.py", line 61, in __call__
    return self.callable(*self.args, **self.kwargs)
  File "/usr/lib/python2.7/site-packages/freeipa_community_portal-0.2.2-py2.7.egg/freeipa_community_portal/app.py", line 59, in GET
    return self._render_registration_form()
  File "/usr/lib/python2.7/site-packages/freeipa_community_portal-0.2.2-py2.7.egg/freeipa_community_portal/app.py", line 76, in _render_registration_form
    captcha = captcha_helper.CaptchaHelper()
  File "/usr/lib/python2.7/site-packages/freeipa_community_portal-0.2.2-py2.7.egg/freeipa_community_portal/model/captcha_wrapper.py", line 61, in __init__
    self.image = self.image_generator.generate(self.solution, format='jpeg').getvalue()
  File "/usr/lib/python2.7/site-packages/captcha-0.2-py2.7.egg/captcha/image.py", line 40, in generate
    im = self.generate_image(chars)
  File "/usr/lib/python2.7/site-packages/captcha-0.2-py2.7.egg/captcha/image.py", line 217, in generate_image
    im = self.create_captcha_image(chars, color, background)
  File "/usr/lib/python2.7/site-packages/captcha-0.2-py2.7.egg/captcha/image.py", line 192, in create_captcha_image
    images.append(_draw_character(c))
  File "/usr/lib/python2.7/site-packages/captcha-0.2-py2.7.egg/captcha/image.py", line 159, in _draw_character
    font = random.choice(self.truefonts)
  File "/usr/lib/python2.7/site-packages/captcha-0.2-py2.7.egg/captcha/image.py", line 118, in truefonts
    for s in self._font_sizes
  File "/usr/lib64/python2.7/site-packages/PIL/ImageFont.py", line 260, in truetype
    return FreeTypeFont(font, size, index, encoding)
  File "/usr/lib64/python2.7/site-packages/PIL/ImageFont.py", line 140, in __init__
    self.font = core.getfont(font, size, index, encoding)
IOError: cannot open resource
frasertweedale commented 8 years ago

OK so it was weird perms for package data (android .ttf) in captcha library.

Uninstall and reinstall fixed it for me:

sudo pip uninstall captcha
sudo pip install captcha