コード例 #1
0
ファイル: vcc_repo.py プロジェクト: fpemud/config-sync
    def _applyMetaData(self):
        """Won't follow symbolic links"""

        ignoreList = self._internal_ignore_list()

        metadataFile = os.path.join(self.dirName, ".metadata")
        cfgObj = ConfigParser.RawConfigParser()
        cfgObj.read(metadataFile)

        for fr in cfgObj.sections():
            f = os.path.join(self.dirName, fr)
            if any(x for x in ignoreList if fnmatch.fnmatch(f, x)):
                continue

            tname = cfgObj.get(fr, "tname")
            mode = cfgObj.get(fr, "mode")
            owner = cfgObj.get(fr, "owner")

            if tname == "symlink":
                assert VccUtil.isTrival(f) and os.path.islink(f)
            elif tname == "dir":
                if not os.path.exists(f):
                    # create directory, but don't modify mtime of parent directory
                    pdir = os.path.dir_name(f)
                    if pdir != self.dirName:
                        tmtime = os.path.getmtime(pdir)
                    os.mkdir(f)
                    if pdir != self.dirName:
                        VccUtil.setFileMtime(pdir, tmtime)
                else:
                    assert VccUtil.isTrival(f) and os.path.isdir(f) and not os.path.islink(f)
            elif tname == "file":
                assert VccUtil.isTrival(f) and os.path.isfile(f) and not os.path.islink(f)
            else:
                assert False
            if not os.path.islink(f):
                VccUtil.shell("/bin/chmod %s \"%s\""%(mode, f))
            VccUtil.shell("/bin/chown -h %s \"%s\""%(owner, f))
コード例 #2
0
ファイル: vcc_repo.py プロジェクト: fpemud/config-sync
def _callGit(dir_name, command, shellMode=""):
    gitDir = os.path.join(dir_name, ".git")
    cmdStr = "/bin/git --git-dir=\"%s\" --work-tree=\"%s\" %s"%(gitDir, dir_name, command)
    return VccUtil.shell(cmdStr, shellMode)