Apologies, that last patch and changes are wrong, although the original
source gives me errors still.  The problem is this:
Using Boinc.tools.get_output_file_path, md5.new raises a TypeError.

The even smaller only adds a try/except there to catch those and produce
the correct path.

Bill


On Tue, Aug 26, 2014 at 4:04 PM, Bill Flynn <[email protected]> wrote:

> 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 a4f6bd4b12b73f40e0876b9a183501befb837e27 Mon Sep 17 00:00:00 2001
From: Bill Flynn <[email protected]>
Date: Tue, 26 Aug 2014 16:44:37 -0400
Subject: [PATCH] RE: Fixed md5 bugs in py/Boinc/tools.py

---
 py/Boinc/tools.py | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/py/Boinc/tools.py b/py/Boinc/tools.py
index fa06c1d..3600e24 100644
--- a/py/Boinc/tools.py
+++ b/py/Boinc/tools.py
@@ -35,14 +35,14 @@ 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:
+    except TypeError:
         checksum = md5.new()
 
     fp = open(path, 'r')
@@ -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(filename).hexdigest()[1:8]
+    except TypeError:
+        s = md5.new(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