Skip to content
This repository has been archived by the owner on Apr 5, 2024. It is now read-only.

Thumbnailing fails when image filenames have non-ASCII characters in them #55

Closed
juyrjola opened this issue Nov 8, 2015 · 2 comments
Closed
Assignees

Comments

@juyrjola
Copy link
Contributor

juyrjola commented Nov 8, 2015

E.g. http://api.hel.fi/respa/resource_image/25?dim=80x80

@akx
Copy link
Contributor

akx commented Nov 8, 2015

Copy-pasting the traceback for future reference:


File "/home/respa/venv/lib/python3.4/site-packages/django/core/handlers/base.py" in get_response
  132.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/respa/venv/lib/python3.4/site-packages/django/views/generic/base.py" in view
  71.             return self.dispatch(request, *args, **kwargs)
File "/home/respa/venv/lib/python3.4/site-packages/django/views/generic/base.py" in dispatch
  89.         return handler(request, *args, **kwargs)
File "./resources/views/images.py" in get
  58.                 'detail': True,
File "/home/respa/venv/lib/python3.4/site-packages/easy_thumbnails/files.py" in get_thumbnail
  509.         thumbnail = self.get_existing_thumbnail(thumbnail_options)
File "/home/respa/venv/lib/python3.4/site-packages/easy_thumbnails/files.py" in get_existing_thumbnail
  475.             exists = self.thumbnail_exists(filename)
File "/home/respa/venv/lib/python3.4/site-packages/easy_thumbnails/files.py" in thumbnail_exists
  588.                 self.source_storage, self.name)
File "/home/respa/venv/lib/python3.4/site-packages/easy_thumbnails/utils.py" in get_modified_time
  146.         modified_time = storage.modified_time(name)
File "/home/respa/venv/lib/python3.4/site-packages/django/core/files/storage.py" in modified_time
  325.         return datetime.fromtimestamp(os.path.getmtime(self.path(name)))
File "/home/respa/venv/lib/python3.4/genericpath.py" in getmtime
  55.     return os.stat(filename).st_mtime

Exception Type: UnicodeEncodeError at /resource_image/25
Exception Value: 'ascii' codec can't encode character '\xe4' in position 38: ordinal not in range(128)

(filename equals '/home/respa/media/resource_images/Ryhmätyötila_yRdsWTi.JPG'`)

I've seen this before... Could whoever is in charge of the server please make sure the process running the app has LC_CTYPE=en_US.UTF-8 (or more broadly LANG=en_US.UTF-8) set for the file system encoding? If it already is so, I'll have to dig in deeper.

@akx akx assigned juyrjola and unassigned akx Nov 8, 2015
@juyrjola
Copy link
Contributor Author

juyrjola commented Nov 8, 2015

Setting LANG in the uwsgi config did indeed fix it. Thanks!

What an interesting bug. It didn't manifest before, because I've usually restarted uwsgi manually, and LANG was then inherited from my environment. When we rebooted the server today, the variable was not set, so the bug bit.

The setting is now included in our Ansible template.

@juyrjola juyrjola closed this as completed Nov 8, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants