[mirrorbrain-commits] [opensuse-svn] r7499 - trunk/tools/download-redirector-v2/mirrordoctor/mb

From: Novell Forge SVN <noreply_at_novell.com>
Date: Fri, 5 Jun 2009 05:14:46 -0600 (MDT)
Author: poeml
Date: 2009-06-05 05:14:44 -0600 (Fri, 05 Jun 2009)
New Revision: 7499

Modified:
   trunk/tools/download-redirector-v2/mirrordoctor/mb/util.py
Log:
- mb file ls --md5: use hashlib module, if available (this fixes a
  DepracationWarning given by Python 2.6 when importing the md5 module)
- remove the b64_md5 function, which is no longer used since a while


Modified: trunk/tools/download-redirector-v2/mirrordoctor/mb/util.py
===================================================================
--- trunk/tools/download-redirector-v2/mirrordoctor/mb/util.py	2009-06-05 08:40:01 UTC (rev 7498)
+++ trunk/tools/download-redirector-v2/mirrordoctor/mb/util.py	2009-06-05 11:14:44 UTC (rev 7499)
@@ -23,11 +23,6 @@
         return '%s (%s AS%s)' % (self.ip, self.prefix, self.asn)
 
 
-def b64_md5(path):
-    import base64, md5
-    return base64.standard_b64encode(md5.md5(path).digest())[:-2]
-
-
 def data_url(basedir, path):
     import os, base64
 
@@ -47,16 +42,23 @@
 
 
 def dgst(file):
-    import md5
+    # Python 2.5 depracates the md5 modules
+    # Python 2.4 doesn't have hashlib yet
+    try:
+        import hashlib
+        md5_hash = hashlib.md5()
+    except ImportError:
+        import md5
+        md5_hash = md5.new()
+
     BUFSIZE = 1024*1024
-    s = md5.new()
     f = open(file, 'r')
     while 1:
         buf = f.read(BUFSIZE)
         if not buf: break
-        s.update(buf)
-    return s.hexdigest()
+        md5_hash.update(buf)
     f.close()
+    return md5_hash.hexdigest()
 
 
 def edit_file(data, boilerplate = None):

_______________________________________________
Opensuse-svn mailing list
Opensuse-svn_at_forge.novell.com
http://forge.novell.com/mailman/listinfo/opensuse-svn


_______________________________________________
mirrorbrain-commits mailing list
Archive: http://mirrorbrain.org/archive/mirrorbrain-commits/

Note: To remove yourself from this list, send a mail with the content
 	unsubscribe
to the address mirrorbrain-commits-request_at_mirrorbrain.org
Received on 2009-06-05Z11:15:25

This archive was generated by hypermail 2.2.0 : 2009-07-10Z19:18:13 GMT