Beispiel #1
0
    def mostRecentlyChangedFile(self, force=False):
        if self.__youngest != (None,None) and not force:
            return self.__youngest

        youngFiles = {} # {timestamp: "filepath"}
        # also check the Manifest file
        file_, mtime = filetool.findYoungest(self.manipath)
        youngFiles[mtime] = file_

        # for each interesting library part
        for category in self.assets:
            catsuffix = self.assets[category]['path']
            if catsuffix is None:  # if this changed recently, the Manifest reflects it
                continue
            if not os.path.isdir(os.path.join(self.path, catsuffix)):
                # this might be a recent change reflected in the parent dirs
                for sepIdx in [0] + [mo.start() for mo in re.finditer("/", catsuffix)]: # check self.path, self.path + "/foo", self.path + "/foo/bar", ...
                    pardir = os.path.join(self.path, catsuffix[:sepIdx])
                    if not os.path.isdir(pardir):
                        break
                    else:
                        mtime = os.stat(pardir).st_mtime
                        youngFiles[mtime] = pardir
            else:
                catPath = os.path.join(self.path, catsuffix)
                # find youngest file
                file_, mtime = filetool.findYoungest(catPath)
                youngFiles[mtime] = file_

        # and return the maximum of those
        youngest = sorted(youngFiles.keys())[-1]
        self.__youngest = (youngFiles[youngest], youngest) # ("filepath", mtime)

        return self.__youngest
Beispiel #2
0
 def check(self, since):
     ylist = []
     for path in self.paths:
         self.console.debug("checking path '%s'" % path)
         part_list = filetool.findYoungest(path, pattern=self.pattern,
             includedirs=self.with_dirs, since=since)
         ylist.extend(part_list)
     return ylist
    def mostRecentlyChangedFile(self):
        youngFiles = {}
        # for each interesting library part
        for category in self.categories:
            catPath = self.categories[category]["path"]
            if category == "translation" and not os.path.isdir(catPath):
                continue
            # find youngest file
            file, mtime = filetool.findYoungest(catPath)
            youngFiles[mtime] = file
            
        # also check the Manifest file
        file, mtime = filetool.findYoungest(self.manifest)
        youngFiles[mtime] = file
        
        # and return the maximum of those
        youngest = sorted(youngFiles.keys())[-1]

        return (youngFiles[youngest], youngest)
Beispiel #4
0
 def _checkToolsNewer_1(self, path, checkFile, context):
     if not os.path.isfile(checkFile):
         return True
     checkFileMTime = os.stat(checkFile).st_mtime
     # find youngst tool file
     _, toolCheckMTime = filetool.findYoungest(os.path.dirname(filetool.root()))
     # compare
     if checkFileMTime < toolCheckMTime:
         return True
     else:
         return False
Beispiel #5
0
 def _checkToolsNewer_1(self, path, checkFile, context):
     if not os.path.isfile(checkFile):
         return True
     checkFileMTime = os.stat(checkFile).st_mtime
     # find youngst tool file
     _, toolCheckMTime = filetool.findYoungest(
         os.path.dirname(filetool.root()))
     # compare
     if checkFileMTime < toolCheckMTime:
         return True
     else:
         return False
Beispiel #6
0
    def mostRecentlyChangedFile(self, force=False, catList=None):
        if self.__youngest != (None, None) and not force:
            return self.__youngest

        if catList is None:
            catList = self.assets

        youngFiles = {}  # {timestamp: "filepath"}
        # also check the Manifest file
        file_, mtime = filetool.findYoungest(self.manipath)
        youngFiles[mtime] = file_

        # for each interesting library part
        for category in catList:
            catsuffix = self.assets[category]['path']
            if catsuffix is None:  # if this changed recently, the Manifest reflects it
                continue
            if not os.path.isdir(os.path.join(self.path, catsuffix)):
                # this might be a recent change reflected in the parent dirs
                for sepIdx in [0] + [
                        mo.start() for mo in re.finditer("/", catsuffix)
                ]:  # check self.path, self.path + "/foo", self.path + "/foo/bar", ...
                    pardir = os.path.join(self.path, catsuffix[:sepIdx])
                    if not os.path.isdir(pardir):
                        break
                    else:
                        mtime = os.stat(pardir).st_mtime
                        youngFiles[mtime] = pardir
            else:
                catPath = os.path.join(self.path, catsuffix)
                # find youngest file
                file_, mtime = filetool.findYoungest(catPath)
                youngFiles[mtime] = file_

        # and return the maximum of those
        youngest = sorted(youngFiles.keys())[-1]
        self.__youngest = (youngFiles[youngest], youngest
                           )  # ("filepath", mtime)

        return self.__youngest
Beispiel #7
0
    def mostRecentlyChangedFile(self, force=False):
        if self.__youngest != (None, None) and not force:
            return self.__youngest

        youngFiles = {}  # {timestamp: "filepath"}
        # for each interesting library part
        for category in self.categories:
            catPath = os.path.join(self.path, self.categories[category]["path"])
            if category == "translation" and not os.path.isdir(catPath):
                continue
            # find youngest file
            file_, mtime = filetool.findYoungest(catPath)
            youngFiles[mtime] = file_

        # also check the Manifest file
        file_, mtime = filetool.findYoungest(self.manifest)
        youngFiles[mtime] = file_

        # and return the maximum of those
        youngest = sorted(youngFiles.keys())[-1]
        self.__youngest = (youngFiles[youngest], youngest)  # ("filepath", mtime)

        return self.__youngest
Beispiel #8
0
    def mostRecentlyChangedFile(self, force=False):
        if self.__youngest != (None, None) and not force:
            return self.__youngest

        youngFiles = {}  # {timestamp: "filepath"}
        # for each interesting library part
        for category in self.assets:
            catPath = os.path.join(self.path, self.assets[category]["path"])
            if category == "translations" and not os.path.isdir(catPath):
                continue
            # find youngest file
            file_, mtime = filetool.findYoungest(catPath)
            youngFiles[mtime] = file_

        # also check the Manifest file
        file_, mtime = filetool.findYoungest(self.manipath)
        youngFiles[mtime] = file_

        # and return the maximum of those
        youngest = sorted(youngFiles.keys())[-1]
        self.__youngest = (youngFiles[youngest], youngest
                           )  # ("filepath", mtime)

        return self.__youngest
Beispiel #9
0
 def watch(self, jobconf, confObj):
     console = Context.console
     since = time.time()
     interval = jobconf.get("watch-files/interval", 2)
     paths = jobconf.get("watch-files/paths", [])
     if not paths:
         return
     include_dirs = jobconf.get("watch-files/include-dirs", False)
     exit_on_retcode = jobconf.get("watch-files/exit-on-retcode", False)
     command = jobconf.get("watch-files/command/line", "")
     if not command:
         return
     command_tmpl = CommandLineTemplate(command)
     per_file = jobconf.get("watch-files/command/per-file", False)
     console.info("Watching changes of '%s'..." % paths)
     console.info("Press Ctrl-C to terminate.")
     pattern = self._watch_pattern(jobconf.get("watch-files/include",[])) 
     while True:
         time.sleep(interval)
         ylist = []
         for path in paths:
             console.debug("checking path '%s'" % path)
             part_list = filetool.findYoungest(path, pattern=pattern, includedirs=include_dirs, since=since)
             ylist.extend(part_list)
         since = time.time()
         if ylist:     # ylist =[(fpath,fstamp)]
             flist = [f[0] for f in ylist]
             cmd_args = {'FILELIST': ' '.join(flist)}
             console.debug("found changed files: %s" % flist)
             try:
                 if not per_file:
                     cmd = command_tmpl.safe_substitute(cmd_args)
                     self.runShellCommand(cmd)
                 else:
                     for fname in flist:
                         cmd_args['FILE']      = fname                       # foo/bar/baz.js
                         cmd_args['DIRNAME']   = os.path.dirname(fname)      # foo/bar
                         cmd_args['BASENAME']  = os.path.basename(fname)     # baz.js
                         cmd_args['EXTENSION'] = os.path.splitext(fname)[1]  # .js
                         cmd_args['FILENAME']  = os.path.basename(os.path.splitext(fname)[0])  # baz
                         cmd = command_tmpl.safe_substitute(cmd_args)
                         self.runShellCommand(cmd)
             except RuntimeError:
                 if exit_on_retcode:
                     raise
                 else:
                     pass
     return