Ejemplo n.º 1
0
 def getmtime(x):
     sft = stat_float_times()
     stat_float_times(True)
     try:
         return _getmtime(x)
     finally:
         stat_float_times(sft)
Ejemplo n.º 2
0
 def getmtime(x):
     sft = stat_float_times()
     stat_float_times(True)
     try:
         return _getmtime(x)
     finally:
         stat_float_times(sft)
Ejemplo n.º 3
0
def find_files_by_mtime(path, dt_from, dt_to):
    """
    Given two timestamps, find files under a path that were
    last modified between the two.

    Parameters
    ----------
    path : str
        The root path from which to start the search
    dt_from : datetime.datetime
        The "starting" point of the search timeframe
    dt_to : datetime.datetime
        The "ending" point of the search timeframe

    Returns
    -------
    files : list
        A list of the files that have modification times within the
        time range provided (sorted by modification time)
    """
    # find only the directories that have been modified between these two
    # timestamps (should be much faster than inspecting all files)
    # Note: this doesn't work reliably, so just look in entire path...
    # dirs = find_dirs_by_mtime(path, dt_from, dt_to)

    dirs = [path]

    # adjust the datetime objects with the tz_offset (usually should be 0)
    dt_from += tz_offset
    dt_to += tz_offset

    files = set()  # use a set here (faster and we won't have duplicates)
    # for each of those directories, walk the file tree and inspect the
    # actual files:
    for d in dirs:
        for dirpath, _, filenames in _os.walk(d):
            for f in filenames:
                fname = _os.path.abspath(_os.path.join(dirpath, f))
                if dt_from.timestamp() < _getmtime(fname) < dt_to.timestamp():
                    files.add(fname)

    # convert the set to a list and sort my mtime
    files = list(files)
    files.sort(key=_getmtime)

    return files
Ejemplo n.º 4
0
def find_dirs_by_mtime(path, dt_from, dt_to):
    """
    Given two timestamps, find the directories under a path that were
    last modified between the two

    .. deprecated:: 0.0.9
          `find_dirs_by_mtime` is not recommended for use to find files for
          record inclusion, because subsequent modifications to a directory
          (e.g. the user wrote a text file or did some analysis afterwards)
          means no files will be returned from that directory (because it is
          not searched)

    Parameters
    ----------
    path : str
        The root path from which to start the search
    dt_from : datetime.datetime
        The "starting" point of the search timeframe
    dt_to : datetime.datetime
        The "ending" point of the search timeframe

    Returns
    -------
    dirs : :obj:`list` of :obj:`str`
        A list of the directories that have modification times within the
        time range provided
    """
    dirs = []

    # adjust the datetime objects with the tz_offset (usually should be 0)
    dt_from += tz_offset
    dt_to += tz_offset

    # use os.walk and only inspect the directories for mtime (much fewer
    # comparisons than looking at every file):
    _logger.info(f'Finding directories modified between {dt_from.isoformat()} '
                 f'and {dt_to.isoformat()}')
    for dirpath, _, _ in _os.walk(path):
        if dt_from.timestamp() < _getmtime(dirpath) < dt_to.timestamp():
            dirs.append(dirpath)
    return dirs
Ejemplo n.º 5
0
The list of variables should (almost) never change, except if
A different protocol is used to generate pynames from var names.
Instead of needing to import and generate at runtime, just import
this python file. This file will automatically raise ValueError
if it detects that the corresponding csv file is out of date.

"""

from os.path import getmtime as _getmtime, dirname as _dirname, join as _join

# Filenames as passed to makevars.make_vars_py()
__curdir = _dirname(__file__)
__module = _join(__curdir, "recipe_vars.py")
__csv = _join(__curdir, "vars_db", "recipe_vars.csv")

if _getmtime(__csv) > _getmtime(__module):
    raise ImportError("Warning! Pyfile is outdated. Regenerate from makevars.py.")

from pbslib.recipemaker import RecipeVariable


pHDeadband = RecipeVariable("pHDeadband")
AlarmBuzzerActual = RecipeVariable("AlarmBuzzerActual")
MFCN2OutRawOn = RecipeVariable("MFCN2OutRaw(V).On(iter)")
PumpsValvesPumpSmplRevrsReq = RecipeVariable("Pumps&ValvesPumpSmplRevrsReq")
CalTempASlope = RecipeVariable("CalTempA.Slope")
AgMainGasUser = RecipeVariable("AgMainGasUser(LPM)")
AgMainGasControlDTime = RecipeVariable("AgMainGasControl.DTime(min)")
DOO2ControlDTime = RecipeVariable("DOO2Control.DTime(min)")
AgMainGasRangeAutoMin = RecipeVariable("AgMainGasRangeAuto(LPM).Min")
DOModeUser = RecipeVariable("DOModeUser")