diff core/management/commands/ssl_images.py @ 981:ef1558941bc9

Additional tweaks to ssl_images.
author Brian Neal <bgneal@gmail.com>
date Sat, 24 Oct 2015 21:29:07 -0500
parents 3ebde23a59d0
children 7db9037915c4
line wrap: on
line diff
--- a/core/management/commands/ssl_images.py	Thu Oct 15 18:35:56 2015 -0500
+++ b/core/management/commands/ssl_images.py	Sat Oct 24 21:29:07 2015 -0500
@@ -70,6 +70,11 @@
     handler.setFormatter(formatter)
     logger.addHandler(handler)
 
+    requests_log = logging.getLogger("requests.packages.urllib3")
+    requests_log.setLevel(logging.INFO)
+    requests_log.propagate = True
+    requests_log.addHandler(handler)
+
 
 def resize_image(img_path):
     """Resizes the image found at img_path if necessary.
@@ -85,8 +90,12 @@
 
     if image.size > PHOTO_MAX_SIZE:
         logger.info('Resizing from %s to %s', image.size, PHOTO_MAX_SIZE)
-        image.thumbnail(PHOTO_MAX_SIZE, Image.ANTIALIAS)
-        image.save(img_path)
+        try:
+            image.thumbnail(PHOTO_MAX_SIZE, Image.ANTIALIAS)
+            image.save(img_path)
+        except IOError as ex:
+            logger.error("Error resizing image from %s: %s", img_path, ex)
+            return False
 
     return True