PATCH: Remove old "copyfile" method from copyfile minion code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



        It appears that once upon a time the act of copying a file involved 
reading a file into memory and passing all of that data to a single method on 
the minion side.  That method was called "copyfile".

        For some reason this method still exists even though it is unused.  
This patch removes that method.

        Note that there are several other bits of code in copyfile which are 
currently unused including the "checksum", "_checksum_blob" and "_backuplocal" 
methods on the minion side and code supporting the "--force" option in the 
cmd_module.  I think that all of these could be useful in the future which is 
why I decided not to remove them.

--
Marcus
>From f7ad8836e01664aaaed9884d81c4726c82d580d8 Mon Sep 17 00:00:00 2001
From: Marcus Lauer <marcuslauer@xxxxxxxxxx>
Date: Wed, 12 Sep 2012 18:56:57 -0400
Subject: [PATCH] CopyFile: remove old copyfile method from minion

---
 func/minion/modules/copyfile.py |   46 ---------------------------------------
 1 files changed, 0 insertions(+), 46 deletions(-)

diff --git a/func/minion/modules/copyfile.py b/func/minion/modules/copyfile.py
index 61c6a4f..d8122b9 100644
--- a/func/minion/modules/copyfile.py
+++ b/func/minion/modules/copyfile.py
@@ -98,52 +98,6 @@ class CopyFile(func_module.FuncModule):
 
         return 1
 
-
-    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)
-        if not os.path.exists(dirpath):
-            os.makedirs(dirpath)
-
-        remote_sum = self._checksum_blob(filebuf.data)
-        local_sum = 0
-        if os.path.exists(filepath):
-            local_sum = self.checksum(filepath)
-
-        if remote_sum != local_sum or force is not None:
-            # back up the localone
-            if os.path.exists(filepath):
-                if not self._backuplocal(filepath):
-                    return -1
-
-            # do the new write
-            try:
-                fo = open(filepath, 'w')
-                fo.write(filebuf.data)
-                fo.close()
-                del fo
-            except (IOError, OSError), e:
-                # XXX logger output here
-                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
-
     def _backuplocal(self, fn):
         """
         make a date-marked backup of the specified file,
-- 
1.7.7

_______________________________________________
func mailing list
func@xxxxxxxxxxxxxxxxxxxxxx
https://lists.fedorahosted.org/mailman/listinfo/func

[Index of Archives]     [Fedora Users]     [Linux Networking]     [Fedora Legacy List]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux