summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Likins <alikins@redhat.com>2007-09-25 15:47:39 -0400
committerAdrian Likins <alikins@redhat.com>2007-09-25 15:47:39 -0400
commitef559785042189dd5a9a4b58312836de11841f17 (patch)
tree4b10d006f286e62c380a59eb2c30910e6d7fe296
parent4d36563e61ab0d0b6617aae18c9a6962701c6c59 (diff)
downloadthird_party-func-ef559785042189dd5a9a4b58312836de11841f17.tar.gz
third_party-func-ef559785042189dd5a9a4b58312836de11841f17.tar.xz
third_party-func-ef559785042189dd5a9a4b58312836de11841f17.zip
add stuff for specify a mode/uid/gid and a "force" just for
kicks
-rw-r--r--modules/copyfile.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/modules/copyfile.py b/modules/copyfile.py
index 7d04abf..58b5ea4 100644
--- a/modules/copyfile.py
+++ b/modules/copyfile.py
@@ -47,10 +47,13 @@ class CopyFile(func_module.FuncModule):
return thissum.hexdigest()
- def copyfile(self, filepath, filebuf):
+ def copyfile(self, filepath, filebuf, mode=0644, uid=0, gid=0, force=None):
# -1 = problem file was not copied
# 1 = file was copied
# 0 = file was not copied b/c file is unchanged
+
+
+ # we should probably verify mode,uid,gid are valid as well
dirpath = os.path.dirname(filepath)
basepath = os.path.basename(filepath)
@@ -62,7 +65,7 @@ class CopyFile(func_module.FuncModule):
if os.path.exists(filepath):
local_sum = self.checksum(filepath)
- if remote_sum != local_sum:
+ if remote_sum != local_sum or force is not None:
# back up the localone
if os.path.exists(filepath):
if not self._backuplocal(filepath):
@@ -79,6 +82,14 @@ class CopyFile(func_module.FuncModule):
return -1
else:
return 0
+
+ # hmm, need to figure out proper exceptions -akl
+ try:
+ # we could intify the mode here if it's a string
+ os.chmod(filepath, mode)
+ os.chown(filepath, uid, gid)
+ except (IOError, OSError), e:
+ return -1
return 1