Hello,

I've started writing a custom assimilator/validator duo for my boinc
application.  I've been looking at the python tools, and it looks like the
md5 utilities located in

py/Boinc/tools.py

are not working properly.  Attached is a small patch that seems to work,
although the fix is pretty simple and the changes are included below so you
don't have to load up the patch to see them.  The patch was created from
the master branch, cloned 08/26/2014.

Thanks,
Bill


In md5_file (line 35), change lines 43-46

    try:
        checksum = md5()
    except NameError:
        checksum = md5.new()
to
    try:
        checksum = md5.new()
    except ValueError:
        checksum = md5.new('md5')


and in get_output_file_path (line 75), change line 81

    s = md5.new(filename).hexdigest()[1:8]
to
    try:
        s = md5.new(filename).hexdigest()[1:8]
    except ValueError:
        s = md5.new('md5', string=filename).hexdigest()[1:8]
From 5c68ebcc2344fed5493d9ffd60cbe874cb7e1cc7 Mon Sep 17 00:00:00 2001
From: Bill Flynn <[email protected]>
Date: Tue, 26 Aug 2014 16:02:01 -0400
Subject: [PATCH] Fixed md5 bugs in py/Boinc/tools.py

---
 py/Boinc/tools.py | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/py/Boinc/tools.py b/py/Boinc/tools.py
index fa06c1d..36d77f7 100644
--- a/py/Boinc/tools.py
+++ b/py/Boinc/tools.py
@@ -35,15 +35,15 @@ def make_uuid():
 def md5_file(path):
     """
     Return a 16-digit MD5 hex digest of a file's contents
-    Read the file in chunks 
+    Read the file in chunks
     """
 
     chunk = 8096
 
     try:
-        checksum = md5()
-    except NameError:
         checksum = md5.new()
+    except ValueError:
+        checksum = md5.new('md5')
 
     fp = open(path, 'r')
     while True:
@@ -78,6 +78,9 @@ def get_output_file_path(filename):
     """
     config = configxml.default_config()
     fanout = long(config.config.uldl_dir_fanout)
-    s = md5.new(filename).hexdigest()[1:8]
+    try:
+        s = md5.new(filename).hexdigest()[1:8]
+    except ValueError:
+        s = md5.new('md5', string=filename).hexdigest()[1:8]
     x = long(s, 16)
-    return "%s/%x/%s" % (config.config.upload_dir, x % fanout, filename) 
+    return "%s/%x/%s" % (config.config.upload_dir, x % fanout, filename)
-- 
1.9.1

_______________________________________________
boinc_dev mailing list
[email protected]
http://lists.ssl.berkeley.edu/mailman/listinfo/boinc_dev
To unsubscribe, visit the above URL and
(near bottom of page) enter your email address.

Reply via email to