Exemplo n.º 1
0
    flags = " ".join(chain([gen], Config.ncsim.get("flags").split()))
    # run simulation
    relog.step("Running simulation")
    executor.sh_exec("xrun %s -f %s" % (flags, SRCS),
                     PARSER_LOG,
                     MAX_TIMEOUT=300)


def run_lint(files, params):
    Config.add_config(os.path.join(TOOLS_DIR, "tools.config"))
    WAVE_FORMAT = Config.xcellium.get("format")
    DEFAULT_TMPDIR = utils.get_tmp_folder("lint")
    SRCS = os.path.join(DEFAULT_TMPDIR, "srcs.list")
    PARSER_LOG = os.path.join(DEFAULT_TMPDIR, "parser.log")
    SIM_LOG = os.path.join(DEFAULT_TMPDIR, "sim.log")
    WAVE = os.path.join(DEFAULT_TMPDIR, "run.%s" % WAVE_FORMAT)
    # generate scripts
    gen = prepare(files, params)
    flags = " ".join(chain([gen, "-hal"], Config.ncsim.get("flags").split()))
    # lint
    executor.sh_exec("xrun %s -f %s" % (flags, SRCS),
                     PARSER_LOG,
                     MAX_TIMEOUT=300)


if __name__ == "__main__":
    # create the list of sources
    PARAMS, MIMES, FILES = utils.get_sources(relog.filter_stream(sys.stdin),
                                             None)
    run_sim(FILES, PARAMS)
Exemplo n.º 2
0
                            NOERR=True)
    proc = next(gen)
    # watch the log file to determine when
    # the simulation ends
    sim_done = watch_log(log)
    if proc:
        proc.kill()
    return 0, not sim_done  # relog.get_stats(SIM_LOG)


def main(files, params):
    top = params.get("TOP_MODULE")
    print(top)
    if not top:
        for file in files:
            print(file)
            if file.endswidth(".asc"):
                top = file
                break
    if top:
        stats = run(top)
        return stats
    else:
        relog.error("No asc file detected")
    return 0, 0


if __name__ == "__main__":
    files, params = utils.get_sources(relog.filter_stream(sys.stdin), None)
    main(files, params)
Exemplo n.º 3
0
def ish_exec(
    cmd: str,
    log: str = None,
    mode: str = "w+",
    MAX_TIMEOUT: int = 300,
    SHOW_CMD: bool = False,
    SHELL: bool = False,
    CWD: str = None,
    ENV: object = None,
    NOERR: bool = False,
):
    """
    simplify code for executing shell command
    """
    tokens = shlex.split(cmd)
    try:
        if CWD is None and ENV is None:
            proc = subprocess.Popen(
                tokens,
                stdout=subprocess.PIPE,
                stderr=subprocess.PIPE if NOERR else subprocess.STDOUT,
                shell=SHELL,
            )
        elif ENV is None:
            proc = subprocess.Popen(
                tokens,
                stdout=subprocess.PIPE,
                stderr=subprocess.PIPE if NOERR else subprocess.STDOUT,
                shell=SHELL,
                cwd=CWD,
            )
        else:
            proc = subprocess.Popen(
                tokens,
                stdout=subprocess.PIPE,
                stderr=subprocess.PIPE if NOERR else subprocess.STDOUT,
                shell=SHELL,
                cwd=CWD,
                env=ENV,
            )
        yield proc
        if log is not None:
            with open(log, mode) as fp:
                if SHOW_CMD:
                    fp.write("%s\n" % cmd)
                for line in proc.stdout:
                    sys.stdout.write(format_line(line.decode("utf-8")))
                    # remove color code of log.vh amond other things
                    content = list(relog.filter_stream(line))
                    if content:
                        fp.write("%s\n" % content[0])
        else:
            for line in proc.stdout:
                sys.stdout.write(format_line(line.decode("utf-8")))
        proc.stdout.close()
        return_code = proc.wait()
        if return_code:
            raise subprocess.CalledProcessError(return_code, cmd)
    except (OSError, subprocess.CalledProcessError):
        return False
    except subprocess.TimeoutExpired:
        relog.error("Unexpected executer timeout")
        return False
    else:
        return True