From bb56e5bf579267d4bc76883ebddcc7c0f8a8852c Mon Sep 17 00:00:00 2001 From: Adrian Likins Date: Wed, 24 Oct 2007 14:34:46 -0400 Subject: change copyfile cmd line to transmit file contents as binary blobs change copyfile minion module to accept blobs, add checksum_blob for doing plain blobs --- func/minion/modules/copyfile.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'func/minion') diff --git a/func/minion/modules/copyfile.py b/func/minion/modules/copyfile.py index a4f91f0..6c81098 100644 --- a/func/minion/modules/copyfile.py +++ b/func/minion/modules/copyfile.py @@ -20,6 +20,10 @@ from modules import func_module class CopyFile(func_module.FuncModule): + version = "0.0.1" + api_version = "0.0.2" + + def __init__(self): self.methods = { @@ -28,6 +32,12 @@ class CopyFile(func_module.FuncModule): } func_module.FuncModule.__init__(self) + def _checksum_blob(self, blob): + CHUNK=2**16 + thissum = sha.new() + thissum.update(blob) + return thissum.hexdigest() + def checksum(self, thing): CHUNK=2**16 @@ -60,7 +70,7 @@ class CopyFile(func_module.FuncModule): if not os.path.exists(dirpath): os.makedirs(dirpath) - remote_sum = self.checksum(filebuf) + remote_sum = self._checksum_blob(filebuf.data) local_sum = 0 if os.path.exists(filepath): local_sum = self.checksum(filepath) @@ -74,7 +84,7 @@ class CopyFile(func_module.FuncModule): # do the new write try: fo = open(filepath, 'w') - fo.write(filebuf) + fo.write(filebuf.data) fo.close() del fo except (IOError, OSError), e: -- cgit