[Erp5-report] r38531 kazuhiko - /erp5/trunk/products/ERP5OOo/tests/testDms.py

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Sep 21 17:49:24 CEST 2010


Author: kazuhiko
Date: Tue Sep 21 17:49:21 2010
New Revision: 38531

URL: http://svn.erp5.org?rev=38531&view=rev
Log:
if PIL is missing, use ImageMagick's identify command.

Modified:
    erp5/trunk/products/ERP5OOo/tests/testDms.py

Modified: erp5/trunk/products/ERP5OOo/tests/testDms.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5OOo/tests/testDms.py?rev=38531&r1=38530&r2=38531&view=diff
==============================================================================
--- erp5/trunk/products/ERP5OOo/tests/testDms.py [utf8] (original)
+++ erp5/trunk/products/ERP5OOo/tests/testDms.py [utf8] Tue Sep 21 17:49:21 2010
@@ -70,7 +70,6 @@ import os
 from threading import Thread
 import httplib
 import urllib
-from PIL import Image
 from AccessControl import Unauthorized
 
 QUIET = 0
@@ -1967,8 +1966,16 @@ return 1
       f.close()
       infile.close()
       file_size = len(image_data)
-      image = Image.open(filename)
-      image_size = image.size
+      try:
+        from PIL import Image
+        image = Image.open(filename)
+        image_size = image.size
+      except ImportError:
+        from subprocess import Popen, PIPE
+        identify_output = Popen(['identify', filename],
+                                stdout=PIPE).communicate()[0]
+        image_size = tuple(map(lambda x:int(x),
+                               identify_output.split()[2].split('x')))
       os.remove(filename)
       return image_size, file_size
 




More information about the Erp5-report mailing list