hashlib not avail. on python2.4/centos5
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Wed, 7 Jul 2010 09:33:17 +0000 (09:33 +0000)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Wed, 7 Jul 2010 09:33:17 +0000 (09:33 +0000)
source/utils.py

index 6cd286a..0ee2008 100644 (file)
@@ -16,7 +16,6 @@ import socket
 import fcntl
 import string
 import exceptions
-import hashlib
 
 from Exceptions import *
 
@@ -255,7 +254,12 @@ def check_file_hash(filename, hash_filename):
 def sha1_file(filename):
     """Calculate sha1 hash of file."""
     try:
-        m = hashlib.sha1()
+        try:
+            import hashlib
+            m = hashlib.sha1()
+        except:
+            import sha
+            m=sha.new()
         f = file(filename, 'rb')
         while True:
             # 256 KB seems ideal for speed/memory tradeoff