[boto commit] r676 - trunk/boto

0 views
Skip to first unread message

codesite...@google.com

unread,
Apr 14, 2008, 1:32:24 AM4/14/08
to boto-...@googlegroups.com
Author: Mitch.Garnaat
Date: Sat Apr 12 14:33:06 2008
New Revision: 676

Modified:
trunk/boto/utils.py

Log:
Need a fallback in case hashlib is not available (i.e. versions prior
to 2.5). Otherwise we get an ImportError.

Modified: trunk/boto/utils.py
==============================================================================
--- trunk/boto/utils.py (original)
+++ trunk/boto/utils.py Sat Apr 12 14:33:06 2008
@@ -47,7 +47,12 @@
import logging.handlers
import boto
import tempfile
-import hashlib
+try:
+ import hashlib
+ _hashfn = hashlib.sha512
+except ImportError:
+ import md5
+ _hashfn = md5.md5

METADATA_PREFIX = 'x-amz-meta-'
AMAZON_HEADER_PREFIX = 'x-amz-'
@@ -429,13 +434,13 @@
self.str = str

def set(self, value):
- self.str = hashlib.sha512(value).hexdigest()
+ self.str = _hashfn(value).hexdigest()

def __str__(self):
return str(self.str)

def __eq__(self, other):
- return str(hashlib.sha512(value).hexdigest()) == str(self.str)
+ return str(_hashfn(value).hexdigest()) == str(self.str)

def __len__(self):
return len(self.str)

Reply all
Reply to author
Forward
0 new messages