Beispiel #1
0
def vars_py_current(csvfile=__VARS_CSV__, pyfile=__VARS_PYFILE__):
    """
    @param csvfile: csvfile of varnames
    @type csvfile: str
    @param pyfile: pyfile corresponding to csvfile
    @type pyfile: str
    @return: True if vars py is up to date.
    @rtype: bool
    """
    from os.path import getmtime as mtime
    try:
        return mtime(csvfile) < mtime(pyfile)
    except FileNotFoundError:
        return False
Beispiel #2
0
def _lib_file_datetime(filename):
    lib_filename = template_common.lib_file_name('analysisData', 'file',
                                                 filename)
    path = simulation_db.simulation_lib_dir(SIM_TYPE).join(lib_filename)
    if path.exists():
        return {filename: path.mtime()}
    pkdlog('error, missing lib file: {}', path)
    return 0
Beispiel #3
0
def _mtime_or_now(path):
    """mtime for path if exists else time.time()

    Args:
        path (py.path):

    Returns:
        int: modification time
    """
    return int(path.mtime() if path.exists() else time.time())
Beispiel #4
0
    compile_flags = flags[target] + args.args.split()

    binary_path = current_dir + '/.' + target + '/' + binary_file
    file_not_exists = not os.path.exists(binary_path)

    if not os.path.exists(current_dir + '/.' + target):
        os.makedirs(current_dir + '/.' + target)

    try:
        try:
            argsfile = os.environ['TEMPDIR']
        except KeyError:
            argsfile = os.path.basename(__file__) + '../tempd'

        argsfile += '/ide-cpp-stdargs'
        creation_time = max(mtime(source_file), mtime(argsfile))

        if file_not_exists or creation_time > mtime(binary_path):
            arglist = ['rustc'] + compile_flags
            arglist = arglist + [source_file, '-o', binary_path]

            rustc = subprocess.Popen(arglist, stdin=None,
                                     stderr=subprocess.STDOUT,
                                     stdout=subprocess.PIPE)

            try:
                out = rustc.communicate(timeout=timeout)[0].decode("utf-8")
            except TimeoutExpired:
                rustc.kill()
                out = rustc.communicate(timeout=timeout)[0].decode("utf-8")