From 2473fe9626ab8e3fcb27c7a31776035527bd712d Mon Sep 17 00:00:00 2001 From: John Rusnak Date: Mon, 22 Jan 2018 15:35:21 -0800 Subject: [PATCH] Isolate Pillow dependency which can fail on some Linux boxes if not everything installed properly --- testdroid/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/testdroid/__init__.py b/testdroid/__init__.py index a982bdc..3ed30f8 100755 --- a/testdroid/__init__.py +++ b/testdroid/__init__.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- import os, sys, requests, json, logging, time, httplib -from PIL import Image from optparse import OptionParser from urlparse import urljoin from collections import namedtuple @@ -569,9 +568,15 @@ def download_test_screenshots(self, project_id, test_run_id): ''' Earlier downloaded images are checked, and if needed re-downloaded. ''' try: + from PIL import Image im=Image.open(full_path) im.verify() logger.info("Screenshot %s already exists - skipping download" % full_path) + except ImportError: + if os.path.isfile(full_path): + logger.info("Screenshot %s already exists - skipping download" % full_path) + else: + raise # jumps to next block except: url = "me/projects/%s/runs/%s/device-runs/%s/screenshots/%s" % (project_id, test_run['id'], device_run['id'], screenshot['id']) prog = DownloadProgressBar()