summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeth Vidal <skvidal@fedoraproject.org>2007-09-25 16:22:18 -0400
committerSeth Vidal <skvidal@fedoraproject.org>2007-09-25 16:22:18 -0400
commit8a2e2059faecc3b4c4b11363d6fd620ec0535bed (patch)
treed24ea4356e8f93c261e230520e571ef51c831859
parent0cab664634d76d771eb88b33b1d94238c2c9a9df (diff)
parentef559785042189dd5a9a4b58312836de11841f17 (diff)
downloadthird_party-func-8a2e2059faecc3b4c4b11363d6fd620ec0535bed.tar.gz
third_party-func-8a2e2059faecc3b4c4b11363d6fd620ec0535bed.tar.xz
third_party-func-8a2e2059faecc3b4c4b11363d6fd620ec0535bed.zip
Merge branch 'master' of ssh://git.fedoraproject.org/git/hosted/func
* 'master' of ssh://git.fedoraproject.org/git/hosted/func: add stuff for specify a mode/uid/gid and a "force" just for
-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