registerguard / ballot

Online and print election results from Lane County, Ore., USA
MIT License
2 stars 0 forks source link

Handle missing/bad image on /ballot/json/ap_elex_stories/ #16

Closed jheasly closed 7 years ago

jheasly commented 7 years ago

Right now a missing .jpeg breaks the feed.

Traceback (most recent call last):

  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 111, in get_response
    response = callback(request, *callback_args, **callback_kwargs)

  File "/usr/local/lib/python2.7/dist-packages/newrelic-2.38.0.31/newrelic/hooks/framework_django.py", line 497, in wrapper
    return wrapped(*args, **kwargs)

  File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py", line 93, in _wrapped_view
    response = view_func(request, *args, **kwargs)

  File "/rgcalendar/oper/projects_root/ballot/views.py", line 318, in json_wire_stories
    first_image_thumb = get_thumbnail(story.image_set.all()[0].image, '200x200', quality=85)

  File "/usr/local/lib/python2.7/dist-packages/sorl/thumbnail/shortcuts.py", line 8, in get_thumbnail
    return default.backend.get_thumbnail(file_, geometry_string, **options)

  File "/usr/local/lib/python2.7/dist-packages/sorl/thumbnail/base.py", line 56, in get_thumbnail
    source_image = default.engine.get_image(source)

  File "/usr/local/lib/python2.7/dist-packages/sorl/thumbnail/engines/pil_engine.py", line 12, in get_image
    buf = StringIO(source.read())

  File "/usr/local/lib/python2.7/dist-packages/sorl/thumbnail/images.py", line 121, in read
    return self.storage.open(self.name).read()

  File "/usr/local/lib/python2.7/dist-packages/cuddlybuddly/storage/s3/storage.py", line 314, in read
    data, etags, content_range = self._storage._read(self.name, *args)

  File "/usr/local/lib/python2.7/dist-packages/cuddlybuddly/storage/s3/storage.py", line 188, in _read
    raise S3Error(response.message)

S3Error: <?xml version="1.0" encoding="UTF-8"?>
<Error><Code>NoSuchKey</Code><Message>The specified key does not exist.</Message><Key>ap/images/Senate_2016_New_Hamshire-6c869501c0d948a6ac8d8747c04a9b1a.JPEG</Key><RequestId>F11D1B15BBB21AA1</RequestId><HostId>pD8ZxjyhDr8/fozwVeu9yOUdwwcdUZzjrRoetqkSPxFK3HDWvSvqF8sQMcv5ZybgH2wes6J/H+4=</HostId></Error>