Skip to content

Commit

Permalink
Do not fail image upload when Exif data is bad.
Browse files Browse the repository at this point in the history
  • Loading branch information
mauritsvanrees committed Nov 5, 2018
1 parent b863da3 commit 0dca380
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions plone/namedfile/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,15 @@ def __init__(self, data=b'', contentType='', filename=None):
'Exif Data: %s', exif_data)
orientation = exif_data['0th'].get(piexif.ImageIFD.Orientation, 1)
if 1 < orientation <= 8:
self.data, self._width, self._height, self.exif = rotate_image(
self.data)
try:
self.data, self._width, self._height, self.exif = \
rotate_image(self.data)
except KeyboardInterrupt:
raise
except Exception as e:
log.warning(
'Error rotating image %s based on exif data.',
filename, exc_info=1)
else:
self.exif = exif_data

Expand Down

1 comment on commit 0dca380

@jenkins-plone-org
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mauritsvanrees Jenkins CI reporting about code analysis
See the full report here: https://jenkins.plone.org/job/package-plone.namedfile/110/violations

plone/namedfile/file.py:267:9: Q001 Remove bad quotes from multiline string.
plone/namedfile/file.py:308:9: Q001 Remove bad quotes from multiline string.
plone/namedfile/file.py:401:37: F841 local variable 'e' is assigned to but never used
plone/namedfile/handler.py:11:23: C812 missing trailing comma
plone/namedfile/interfaces.py:17:25: C812 missing trailing comma
plone/namedfile/scaling.py:193:25: C815 missing trailing comma in Python 3.5+
plone/namedfile/scaling.py:196:5: C901 'DefaultImageScalingFactory.__call__' is too complex (15)
plone/namedfile/scaling.py:203:25: C816 missing trailing comma in Python 3.6+
plone/namedfile/scaling.py:243:29: C815 missing trailing comma in Python 3.5+
plone/namedfile/scaling.py:407:21: C816 missing trailing comma in Python 3.6+
plone/namedfile/scaling.py:434:25: C815 missing trailing comma in Python 3.5+
plone/namedfile/scaling.py:446:25: C815 missing trailing comma in Python 3.5+
plone/namedfile/scaling.py:460:21: C816 missing trailing comma in Python 3.6+
plone/namedfile/scaling.py:486:29: C815 missing trailing comma in Python 3.5+
plone/namedfile/scaling.py:500:17: C816 missing trailing comma in Python 3.6+
plone/namedfile/testing.py:5:1: I004 isort found an unexpected blank line in imports
plone/namedfile/testing.py:18:9: D001 found xmlconfig.file( replace it with self.loadZCML(
plone/namedfile/tests/test_blobfile.py:40:31: C812 missing trailing comma
plone/namedfile/tests/test_blobfile.py:45:35: C812 missing trailing comma
plone/namedfile/tests/test_blobfile.py:50:46: C812 missing trailing comma
plone/namedfile/tests/test_blobfile.py:55:32: C812 missing trailing comma
plone/namedfile/tests/test_doctests.py:26:17: Q000 Remove bad quotes.
plone/namedfile/tests/test_doctests.py:26:30: Q000 Remove bad quotes.
plone/namedfile/tests/test_doctests.py:47:10: C812 missing trailing comma
plone/namedfile/tests/test_image.py:25:80: E501 line too long (80 > 79 characters)
plone/namedfile/tests/test_scaling.py:85:80: E501 line too long (86 > 79 characters)
plone/namedfile/tests/test_scaling.py:102:80: E501 line too long (81 > 79 characters)
plone/namedfile/tests/test_scaling.py:133:80: E501 line too long (86 > 79 characters)
plone/namedfile/tests/test_scaling.py:156:80: E501 line too long (86 > 79 characters)
plone/namedfile/tests/test_scaling.py:178:80: E501 line too long (86 > 79 characters)
plone/namedfile/tests/test_scaling.py:200:80: E501 line too long (86 > 79 characters)
plone/namedfile/tests/test_scaling_functional.py:112:28: C812 missing trailing comma
plone/namedfile/tests/test_scaling_functional.py:142:70: C812 missing trailing comma
plone/namedfile/tests/test_scaling_functional.py:149:76: C812 missing trailing comma
plone/namedfile/tests/test_scaling_functional.py:160:74: C812 missing trailing comma
plone/namedfile/tests/test_scaling_functional.py:193:75: C812 missing trailing comma
plone/namedfile/tests/test_scaling_functional.py:198:78: C812 missing trailing comma
plone/namedfile/utils/__init__.py:84:66: C812 missing trailing comma
plone/namedfile/utils/__init__.py:151:15: T000 Todo note found.
plone/namedfile/utils/__init__.py:156:73: C812 missing trailing comma
plone/namedfile/utils/__init__.py:176:15: T000 Todo note found.
plone/namedfile/utils/__init__.py:183:18: C812 missing trailing comma
plone/namedfile/utils/__init__.py:188:1: C901 'rotate_image' is too complex (20)
plone/namedfile/utils/__init__.py:219:14: C812 missing trailing comma
plone/namedfile/utils/__init__.py:271:25: F821 undefined name 'StringIO'
plone/namedfile/utils/__init__.py:276:1: E302 expected 2 blank lines, found 1
plone/namedfile/utils/__init__.py:280:1: E302 expected 2 blank lines, found 1
plone/namedfile/utils/tiff_utils.py:11:1: C901 'process_tiff' is too complex (11)
plone/namedfile/utils/tiff_utils.py:20:7: T000 Todo note found.
plone/namedfile/utils/tiff_utils.py:81:7: T000 Todo note found.
plone/namedfile/utils/tiff_utils.py:82:7: T000 Todo note found.

Follow these instructions to reproduce it locally.

Please sign in to comment.