diff options
author | Adrian Likins <alikins@grimlock.devel.redhat.com> | 2007-10-24 14:34:46 -0400 |
---|---|---|
committer | Adrian Likins <alikins@grimlock.devel.redhat.com> | 2007-10-24 14:34:46 -0400 |
commit | bb56e5bf579267d4bc76883ebddcc7c0f8a8852c (patch) | |
tree | 2c7ee275149336990a15dab3f1335e8fa731280e /func/minion | |
parent | f01c90d5bdd39dd4061276985233b4880783116a (diff) | |
download | func-bb56e5bf579267d4bc76883ebddcc7c0f8a8852c.tar.gz func-bb56e5bf579267d4bc76883ebddcc7c0f8a8852c.tar.xz func-bb56e5bf579267d4bc76883ebddcc7c0f8a8852c.zip |
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
Diffstat (limited to 'func/minion')
-rw-r--r-- | func/minion/modules/copyfile.py | 14 |
1 files changed, 12 insertions, 2 deletions
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: |