本文整理汇总了Python中vunit.ostools.Process.consume_output方法的典型用法代码示例。如果您正苦于以下问题:Python Process.consume_output方法的具体用法?Python Process.consume_output怎么用?Python Process.consume_output使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vunit.ostools.Process
的用法示例。
在下文中一共展示了Process.consume_output方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _create_vsim_process
# 需要导入模块: from vunit.ostools import Process [as 别名]
# 或者: from vunit.ostools.Process import consume_output [as 别名]
def _create_vsim_process(self):
"""
Create the vsim process
"""
ident = threading.current_thread().ident
with self._lock:
try:
vsim_process = self._vsim_processes[ident]
if vsim_process.is_alive():
return vsim_process
except KeyError:
pass
transcript_id = self._transcript_id
self._transcript_id += 1
vsim_process = Process([join(self._prefix, "vsim"), "-c",
"-l", join(dirname(self._modelsim_ini), "transcript%i" % transcript_id)])
self._vsim_processes[ident] = vsim_process
vsim_process.write("#VUNIT_RETURN\n")
try:
consumer = SilentOutputConsumer()
vsim_process.consume_output(consumer)
except Process.NonZeroExitCode:
# Print output if background vsim process startup failed
LOGGER.error("Failed to start re-usable background vsim process")
print(consumer.output)
raise
return vsim_process
示例2: _create_vsim_process
# 需要导入模块: from vunit.ostools import Process [as 别名]
# 或者: from vunit.ostools.Process import consume_output [as 别名]
def _create_vsim_process(self):
"""
Create the vsim process
"""
ident = threading.current_thread().ident
with self._lock:
try:
vsim_process = self._vsim_processes[ident]
if vsim_process.is_alive():
return vsim_process
except KeyError:
pass
transcript_id = self._transcript_id
self._transcript_id += 1
vsim_process = Process([
join(self._prefix, "vsim"), "-c", "-l",
join(dirname(self._modelsim_ini),
"transcript%i" % transcript_id)])
self._vsim_processes[ident] = vsim_process
vsim_process.write("#VUNIT_RETURN\n")
vsim_process.consume_output(silent_output_consumer)
return vsim_process
示例3: simulate
# 需要导入模块: from vunit.ostools import Process [as 别名]
# 或者: from vunit.ostools.Process import consume_output [as 别名]
def simulate(self, # pylint: disable=too-many-arguments, too-many-locals
output_path, library_name, entity_name, architecture_name, config):
"""
Simulate with entity as top level using generics
"""
assert config.pli == []
ghdl_output_path = join(output_path, self.name)
data_file_name = join(ghdl_output_path, "wave.%s" % self._gtkwave)
if not exists(ghdl_output_path):
os.makedirs(ghdl_output_path)
launch_gtkwave = self._gtkwave is not None and not config.elaborate_only
status = True
try:
cmd = []
cmd += ['--elab-run']
cmd += ['--std=%s' % self._std_str()]
cmd += ['--work=%s' % library_name]
cmd += ['--workdir=%s' % self._libraries[library_name]]
cmd += ['-P%s' % path for path in self._libraries.values()]
if self._has_output_flag():
cmd += ['-o', join(ghdl_output_path, "%s-%s" % (entity_name, architecture_name))]
cmd += config.options.get("ghdl_flags", [])
cmd += [entity_name, architecture_name]
for name, value in config.generics.items():
cmd += ['-g%s=%s' % (name, value)]
cmd += ['--assert-level=%s' % ("warning" if config.fail_on_warning else "error")]
if config.disable_ieee_warnings:
cmd += ["--ieee-asserts=disable"]
if config.elaborate_only:
cmd += ["--no-run"]
if launch_gtkwave:
if exists(data_file_name):
os.remove(data_file_name)
if self._gtkwave == "ghw":
cmd += ['--wave=%s' % data_file_name]
elif self._gtkwave == "vcd":
cmd += ['--vcd=%s' % data_file_name]
proc = Process(['ghdl'] + cmd)
proc.consume_output()
except Process.NonZeroExitCode:
status = False
if launch_gtkwave:
cmd = ["gtkwave"] + shlex.split(self._gtkwave_args) + [data_file_name]
stdout.write("%s\n" % " ".join(cmd))
subprocess.call(cmd)
return status
示例4: compile_verilog_file
# 需要导入模块: from vunit.ostools import Process [as 别名]
# 或者: from vunit.ostools.Process import consume_output [as 别名]
def compile_verilog_file(self, source_file_name, library_name):
try:
proc = Process(['vlog', '-sv', '-quiet', '-modelsimini', self._modelsim_ini,
'-work', library_name, source_file_name])
proc.consume_output()
except Process.NonZeroExitCode:
return False
return True
示例5: compile_vhdl_file
# 需要导入模块: from vunit.ostools import Process [as 别名]
# 或者: from vunit.ostools.Process import consume_output [as 别名]
def compile_vhdl_file(self, source_file_name, library_name, vhdl_standard):
try:
proc = Process(['vcom', '-quiet', '-modelsimini', self._modelsim_ini,
'-' + vhdl_standard, '-work', library_name, source_file_name])
proc.consume_output()
except Process.NonZeroExitCode:
return False
return True
示例6: test_parses_stderr
# 需要导入模块: from vunit.ostools import Process [as 别名]
# 或者: from vunit.ostools.Process import consume_output [as 别名]
def test_parses_stderr(self):
python_script = self.make_file("run_err.py", r"""
from sys import stderr
stderr.write("error\n")
""")
process = Process([sys.executable, python_script])
output = []
process.consume_output(output.append)
self.assertEqual(output, ["error"])
示例7: test_parses_stderr
# 需要导入模块: from vunit.ostools import Process [as 别名]
# 或者: from vunit.ostools.Process import consume_output [as 别名]
def test_parses_stderr(self):
python_script = self.make_file("run_err.py", r"""
from sys import stderr
stderr.write("error\n")
""")
process = Process(["python", python_script])
output = []
process.consume_output(lambda line: output.append(line))
self.assertEqual(output, ["error"])
self.assertEqual(process.output, "error\n")
示例8: supports_vhdl_package_generics
# 需要导入模块: from vunit.ostools import Process [as 别名]
# 或者: from vunit.ostools.Process import consume_output [as 别名]
def supports_vhdl_package_generics(cls):
"""
Returns True when this simulator supports VHDL package generics
"""
proc = Process([join(cls.find_prefix(), 'vcom'), '-version'], env=cls.get_env())
consumer = VersionConsumer()
proc.consume_output(consumer)
if consumer.major is not None:
return consumer.minor >= 1 if consumer.major == 10 else consumer.major > 10
return False
示例9: test_run_basic_subprocess
# 需要导入模块: from vunit.ostools import Process [as 别名]
# 或者: from vunit.ostools.Process import consume_output [as 别名]
def test_run_basic_subprocess(self):
python_script = self.make_file("run_basic.py", r"""
from sys import stdout
stdout.write("foo\n")
stdout.write("bar\n")
""")
output = []
process = Process([sys.executable, python_script])
process.consume_output(output.append)
self.assertEqual(output, ["foo", "bar"])
示例10: run_command
# 需要导入模块: from vunit.ostools import Process [as 别名]
# 或者: from vunit.ostools.Process import consume_output [as 别名]
def run_command(command, cwd=None, env=None):
"""
Run a command
"""
try:
proc = Process(command, cwd=cwd, env=env)
proc.consume_output()
return True
except Process.NonZeroExitCode:
pass
return False
示例11: compile_vhdl_file
# 需要导入模块: from vunit.ostools import Process [as 别名]
# 或者: from vunit.ostools.Process import consume_output [as 别名]
def compile_vhdl_file(self, source_file_name, library_name, vhdl_standard):
"""
Compiles a vhdl file into a specific library using a specfic vhdl_standard
"""
try:
proc = Process([join(self._prefix, 'vcom'), '-dbg', '-quiet', '-j', dirname(self._library_cfg),
'-' + vhdl_standard, '-work', library_name, source_file_name])
proc.consume_output()
except Process.NonZeroExitCode:
return False
return True
示例12: run_command
# 需要导入模块: from vunit.ostools import Process [as 别名]
# 或者: from vunit.ostools.Process import consume_output [as 别名]
def run_command(command):
"""
Run a command
"""
try:
proc = Process(command)
proc.consume_output()
return True
except Process.NonZeroExitCode:
pass
return False
示例13: get_osvvm_coverage_api
# 需要导入模块: from vunit.ostools import Process [as 别名]
# 或者: from vunit.ostools.Process import consume_output [as 别名]
def get_osvvm_coverage_api(cls):
"""
Returns simulator name when OSVVM coverage API is supported, None otherwise.
"""
proc = Process([join(cls.find_prefix(), 'vcom'), '-version'])
consumer = VersionConsumer()
proc.consume_output(consumer)
if consumer.year is not None:
if (consumer.year == 2016 and consumer.month >= 10) or (consumer.year > 2016):
return cls.name
return None
示例14: test_run_basic_subprocess
# 需要导入模块: from vunit.ostools import Process [as 别名]
# 或者: from vunit.ostools.Process import consume_output [as 别名]
def test_run_basic_subprocess(self):
python_script = self.make_file("run_basic.py", r"""
from sys import stdout
stdout.write("foo\n")
stdout.write("bar\n")
""")
output = []
process = Process(["python", python_script])
process.consume_output(lambda line: output.append(line))
self.assertEqual(output, ["foo", "bar"])
self.assertEqual(process.output, "foo\nbar\n")
示例15: _run_batch_file
# 需要导入模块: from vunit.ostools import Process [as 别名]
# 或者: from vunit.ostools.Process import consume_output [as 别名]
def _run_batch_file(self, batch_file_name, gui=False):
"""
Run a test bench in batch by invoking a new vsim process from the command line
"""
try:
args = [join(self._prefix, "vsim"), "-gui" if gui else "-c",
"-l", join(dirname(batch_file_name), "transcript"),
'-do', "source \"%s\"" % fix_path(batch_file_name)]
proc = Process(args, cwd=dirname(self._sim_cfg_file_name))
proc.consume_output()
except Process.NonZeroExitCode:
return False
return True