Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gracefully continue reprocessing photos if a file is missing #2

Open
kamykaze opened this issue Nov 30, 2012 · 0 comments
Open

Gracefully continue reprocessing photos if a file is missing #2

kamykaze opened this issue Nov 30, 2012 · 0 comments

Comments

@kamykaze
Copy link

Traceback (most recent call last):
File "manage.py", line 11, in
execute_manager(settings)
File "/Users/kam/dev/projects/webcube-littlegiraffe42/littlegiraffe/django/core/management/init.py", line 438, in execute_manager
utility.execute()
File "/Users/kam/dev/projects/webcube-littlegiraffe42/littlegiraffe/django/core/management/init.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/kam/dev/projects/webcube-littlegiraffe42/littlegiraffe/django/core/management/base.py", line 191, in run_from_argv
self.execute(_args, *_options.dict)
File "/Users/kam/dev/projects/webcube-littlegiraffe42/littlegiraffe/django/core/management/base.py", line 220, in execute
output = self.handle(_args, *_options)
File "/Users/kam/dev/virtualenvs/littlegiraffe42/lib/python2.7/site-packages/photoprocessor/management/commands/reprocess_photos.py", line 33, in handle
self.reprocess_model(model, image_fields, kwargs['force'])
File "/Users/kam/dev/virtualenvs/littlegiraffe42/lib/python2.7/site-packages/photoprocessor/management/commands/reprocess_photos.py", line 42, in reprocess_model
val.reprocess(save=False, force_reprocess=force)
File "/Users/kam/dev/virtualenvs/littlegiraffe42/lib/python2.7/site-packages/photoprocessor/fields.py", line 255, in reprocess
self.reprocess_info(save=False)
File "/Users/kam/dev/virtualenvs/littlegiraffe42/lib/python2.7/site-packages/photoprocessor/fields.py", line 224, in reprocess_info
source_image = self.image()
File "/Users/kam/dev/virtualenvs/littlegiraffe42/lib/python2.7/site-packages/photoprocessor/fields.py", line 155, in image
self.file.open()
File "/Users/kam/dev/projects/webcube-littlegiraffe42/littlegiraffe/django/db/models/fields/files.py", line 52, in _get_file
self._file = self.storage.open(self.name, 'rb')
File "/Users/kam/dev/projects/webcube-littlegiraffe42/littlegiraffe/django/core/files/storage.py", line 33, in open
file = self._open(name, mode)
File "/Users/kam/dev/projects/webcube-littlegiraffe42/littlegiraffe/django/core/files/storage.py", line 159, in _open
return File(open(self.path(name), mode))
IOError: [Errno 2] No such file or directory: u'/Users/kam/dev/projects/webcube-littlegiraffe42/littlegiraffe/public/media/products/2010/09/23/lxthron_2.jpg'

While we should never have missing files in normal circumstances, it would be nice to catch that exception and keep running the reprocess_photos command

This is accomplished pretty easily by editing management/commands/reprocess_photos.py:

and changing:

val.reprocess(save=False, force_reprocess=force)

to:

try:
val.reprocess(save=False, force_reprocess=force)
except IOError:
print "File not found: %s. Could not reprocess image for model: %s"%(val.url, model)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant