Signed-off-by: Greg Swift <gregswift@xxxxxxxxx> --- func/minion/modules/getfile.py | 17 ++++++++++++++--- func/overlord/modules/getfile.py | 22 +++++++++++++++++----- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/func/minion/modules/getfile.py b/func/minion/modules/getfile.py index b2f23b1..1b54791 100644 --- a/func/minion/modules/getfile.py +++ b/func/minion/modules/getfile.py @@ -15,13 +15,24 @@ """Get a file, chunk by chunk. Minion side.""" import sys -import sha import func_module try: + # py 2.4+ + import hashlib +except ImportError: + # py 2.3 support for RHEL4 + import sha + class hashlib: + @staticmethod + def new(algo): + if algo == 'sha1': + return sha.new() + raise ValueError, "Bad checksum type" +try: # py 2.4 from base64 import b64encode except ImportError: -# py 2.3 +# py 2.3 for RHEL4 from base64 import encodestring as b64encode @@ -56,7 +67,7 @@ class GetFile(func_module.FuncModule): return(checksum, '') fic.seek(bufsize*chunknum) chunk = b64encode(fic.read(bufsize)) - mysha = sha.new() + mysha = hashlib.new('sha1') mysha.update(chunk) checksum = mysha.hexdigest() fic.close() diff --git a/func/overlord/modules/getfile.py b/func/overlord/modules/getfile.py index 8c4ffd2..7050c41 100644 --- a/func/overlord/modules/getfile.py +++ b/func/overlord/modules/getfile.py @@ -16,12 +16,24 @@ """Get a file on the minions, chunk by chunk. Overlord side.""" from func.overlord import overlord_module import os -import sha + +try: + # py 2.4+ + import hashlib +except ImportError: + # py 2.3 support for RHEL4 + import sha + class hashlib: + @staticmethod + def new(algo): + if algo == 'sha1': + return sha.new() + raise ValueError, "Bad checksum type" try: - # py 2.4 + # py 2.4+ from base64 import b64decode except ImportError: - # py 2.3 + # py 2.3 support for RHEL4 from base64 import decodestring as b64decode class getfile(overlord_module.BaseModule): @@ -53,7 +65,7 @@ class getfile(overlord_module.BaseModule): status = 1 return status, msg - nullsha = sha.new().hexdigest() + nullsha = hashlib.new('sha1').hexdigest() sourcebasename = os.path.basename(source) excluderrlist = [] @@ -70,7 +82,7 @@ class getfile(overlord_module.BaseModule): # Probably a REMOTE_ERROR excluderrlist.append(minion) continue - mysha = sha.new() + mysha = hashlib.new('sha1') mysha.update(chunk) if checksum == -1: # On this minion there was no file to get -- 1.7.4 _______________________________________________ Func-list mailing list Func-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/func-list