Skip to content

Commit d8236ed

Browse files
author
Atte Keltanen
committed
use imghdr to verify downloaded images instead of pillow
1 parent 46c39c7 commit d8236ed

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
long_description="""\
1212
Testdroid API client for Python""",
1313
classifiers=['Operating System :: OS Independent',
14-
'Topic :: Software Development',
14+
'Topic :: Software Development',
1515
'Intended Audience :: Developers'], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
1616
keywords='testdroid rest api client',
1717
author='Henri Kivelä <[email protected]>, Sakari Rautiainen <[email protected]>, Teppo Malinen <[email protected]>, Jarno Tuovinen <[email protected]>',
@@ -22,12 +22,12 @@
2222
include_package_data=True,
2323
zip_safe=True,
2424
install_requires=[
25-
'requests', 'pillow',
25+
'requests',
2626
],
2727

2828
entry_points = {
2929
'console_scripts': [
30-
'testdroid = testdroid:main',
30+
'testdroid = testdroid:main',
3131
],
3232
},
3333
)

testdroid/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22

3-
import os, sys, requests, json, logging, time, base64
3+
import os, sys, requests, json, logging, time, base64, imghdr
44

55
if sys.version_info[0] > 2:
66
import http.client
@@ -684,12 +684,12 @@ def download_test_screenshots(self, project_id, test_run_id):
684684
''' Earlier downloaded images are checked, and if needed re-downloaded.
685685
'''
686686
try:
687-
from PIL import Image
688-
im=Image.open(full_path)
689-
im.verify()
690-
logger.info("Screenshot %s already exists - skipping download" % full_path)
687+
if imghdr.what(full_path) in ['jpeg', 'png']:
688+
logger.info("Screenshot %s already exists - skipping download" % full_path)
689+
else:
690+
raise
691691
except ImportError:
692-
if os.path.isfile(full_path): # fallback if Pillow fails to import
692+
if os.path.isfile(full_path): # fallback if a valid image header can't be found
693693
logger.info("Screenshot %s already exists - skipping download" % full_path)
694694
else:
695695
raise # jump to next block

0 commit comments

Comments
 (0)