[molecule.utils] make md5sum() working with Python3.x

This commit is contained in:
Fabio Erculiani
2010-06-29 11:09:25 +02:00
parent c30e2b25d5
commit 977b69a4b5
+5 -3
View File
@@ -22,6 +22,8 @@ import time
import subprocess
import shutil
from molecule.compat import convert_to_rawstring
RUNNING_PIDS = set()
def get_year():
@@ -90,10 +92,10 @@ def get_random_number():
def md5sum(filepath):
import hashlib
m = hashlib.md5()
readfile = open(filepath)
readfile = open(filepath, "rb")
block = readfile.read(1024)
while block:
m.update(block)
m.update(convert_to_rawstring(block))
block = readfile.read(1024)
readfile.close()
return m.hexdigest()
@@ -111,4 +113,4 @@ def print_traceback(f = None):
@type f: valid file handle
"""
import traceback
traceback.print_exc(file = f)
traceback.print_exc(file = f)