当前位置: 首页>>代码示例>>Python>>正文


Python Process._next方法代码示例

本文整理汇总了Python中vunit.ostools.Process._next方法的典型用法代码示例。如果您正苦于以下问题:Python Process._next方法的具体用法?Python Process._next怎么用?Python Process._next使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vunit.ostools.Process的用法示例。


在下文中一共展示了Process._next方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_output_is_parallel

# 需要导入模块: from vunit.ostools import Process [as 别名]
# 或者: from vunit.ostools.Process import _next [as 别名]
    def test_output_is_parallel(self):
        python_script = self.make_file("run_timeout.py", r"""
from time import sleep
from sys import stdout
stdout.write("message\n")
stdout.flush()
sleep(1000)
""")

        process = Process(["python", python_script])
        message = process._next()
        process.terminate()
        self.assertEqual(message, "message")
开发者ID:tomasnilefrost,项目名称:vunit,代码行数:15,代码来源:test_ostools.py

示例2: __init__

# 需要导入模块: from vunit.ostools import Process [as 别名]
# 或者: from vunit.ostools.Process import _next [as 别名]

#.........这里部分代码省略.........

    def _create_batch_script(self, common_file_name, load_only=False):
        """
        Create tcl script to run in batch mode
        """
        batch_do = "do " + fix_path(common_file_name) + "\n"
        batch_do += "quietly set failed [vunit_load]\n"
        batch_do += "if {$failed} {quit -f -code 1}\n"
        if not load_only:
            batch_do += "quietly set failed [vunit_run]\n"
            batch_do += "if {$failed} {quit -f -code 1}\n"
        batch_do += "quit -f -code 0\n"
        return batch_do

    def _create_user_script(self, common_file_name):
        tcl = "do %s\n" % fix_path(common_file_name)
        tcl += "vunit_help\n"
        return tcl

    def _run_batch_file(self, batch_file_name, gui=False):
        try:
            args = ['vsim', '-quiet',
                    "-l", join(dirname(batch_file_name), "transcript"),
                    '-do', "do %s" % fix_path(batch_file_name)]
            
            if gui:
                args.append('-gui')
            else:
                args.append('-c')

            proc = Process(args)
            proc.consume_output()
        except Process.NonZeroExitCode:
            return False
        return True

    def _send_command(self, cmd):
        self._vsim_process.write("%s\n" % cmd)
        self._vsim_process._next()
        self._vsim_process.write("#VUNIT_RETURN\n")
        self._vsim_process.consume_output(OutputConsumer())

    def _read_var(self, varname):
        self._vsim_process.write("echo $%s #VUNIT_READVAR\n" % varname)
        self._vsim_process._next()
        self._vsim_process.write("#VUNIT_RETURN\n")
        consumer = OutputConsumer(silent=True)
        self._vsim_process.consume_output(consumer)
        return consumer.var

    def _run_persistent(self, common_file_name, load_only=False):
        try:
            self._send_command("quit -sim")
            self._send_command("do " + fix_path(common_file_name))
            self._send_command("quietly set failed [vunit_load]")
            if self._read_var("failed") == '1':
                return False

            if not load_only:
                self._send_command("quietly set failed [vunit_run]")
                if self._read_var("failed") == '1':
                    return False

            return True
        except Process.NonZeroExitCode:
            self._create_vsim_process()
            return False

    def simulate(self, output_path, library_name, entity_name, architecture_name=None, generics=None, pli=None, load_only=None, fail_on_warning=False):
        generics = {} if generics is None else generics
        pli = [] if pli is None else pli
        msim_output_path = abspath(join(output_path, "msim"))
        common_file_name = join(msim_output_path, "common.do")
        user_file_name = join(msim_output_path, "user.do")
        batch_file_name = join(msim_output_path, "batch.do")

        common_do = self._create_common_script(library_name, entity_name, architecture_name, generics, pli,
                                               fail_on_warning=fail_on_warning,
                                               output_path=msim_output_path)
        user_do = self._create_user_script(common_file_name)
        batch_do = self._create_batch_script(common_file_name, load_only)
        write_file(common_file_name, common_do)
        write_file(user_file_name, user_do)
        write_file(batch_file_name, batch_do)

        if self._gui:
            success = self._run_batch_file(user_file_name, gui=True)
        elif self._vsim_process is None:
            success = self._run_batch_file(batch_file_name)
        else:
            success = self._run_persistent(common_file_name, load_only)

        return success

    def load(self, output_path, library_name, entity_name, architecture_name=None, generics=None, pli=None):
        return self.simulate(output_path, library_name, entity_name, architecture_name, generics, pli, load_only=True)

    def __del__(self):
        if self._vsim_process is not None:
            del self._vsim_process
开发者ID:tomasnilefrost,项目名称:vunit,代码行数:104,代码来源:modelsim_interface.py


注:本文中的vunit.ostools.Process._next方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。