func/minion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 func/minion/modules/copyfile.py |   17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

New commits:
commit 40457674d0e8787d61947ccb0d51406ce8ecbcff
Author: Seth Vidal <skvidal@xxxxxxxxxxxxxxxxx>
Date:   Fri Apr 23 11:04:59 2010 -0400

    cleanup the import sha's from func copyfile so we don't emit a deprecation
    notice on python 2.5 and up

diff --git a/func/minion/modules/copyfile.py b/func/minion/modules/copyfile.py
index 8ae3351..e9411ab 100644
--- a/func/minion/modules/copyfile.py
+++ b/func/minion/modules/copyfile.py
@@ -8,8 +8,19 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
+try:
+    import hashlib
+except ImportError:
+    # Python-2.4.z ... gah! (or even 2.3!)
+    import sha
+    class hashlib:
+        @staticmethod
+        def new(algo):
+            if algo == 'sha1':
+                return sha.new()
+            raise ValueError, "Bad checksum type"
+
 
-import sha
 import os
 import time
 import shutil
@@ -24,14 +35,14 @@ class CopyFile(func_module.FuncModule):
     description = "Allows for smart copying of a file."
 
     def _checksum_blob(self, blob):
-        thissum = sha.new()
+        thissum = hashlib.new('sha1')
         thissum.update(blob)
         return thissum.hexdigest()
                        
     def checksum(self, thing):
 
         CHUNK=2**16
-        thissum = sha.new()
+        thissum = hashlib.new('sha1')
         if os.path.exists(thing):
             fo = open(thing, 'r', CHUNK)
             chunk = fo.read


_______________________________________________
Func-list mailing list
Func-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/func-list

[Index of Archives]     [Fedora Users]     [Linux Networking]     [Fedora Legacy List]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux