From 977b69a4b5fae8f69277660bf0055efe110d5160 Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Tue, 29 Jun 2010 11:09:25 +0200 Subject: [PATCH] [molecule.utils] make md5sum() working with Python3.x --- molecule/utils.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/molecule/utils.py b/molecule/utils.py index e469152..014beaf 100644 --- a/molecule/utils.py +++ b/molecule/utils.py @@ -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) \ No newline at end of file + traceback.print_exc(file = f)