From 9e6f9759d715442536eb0bd3368bcabab904b327 Mon Sep 17 00:00:00 2001 From: tangxifan Date: Wed, 13 Nov 2024 12:27:33 -0800 Subject: [PATCH] [test] fixed the bugs in unicode failures. Refer to ttps://github.com/davidbombal/red-python-scripts/issues/4 --- openfpga_flow/scripts/run_fpga_flow.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/openfpga_flow/scripts/run_fpga_flow.py b/openfpga_flow/scripts/run_fpga_flow.py index 1cb3bc8a6..b919d54d3 100644 --- a/openfpga_flow/scripts/run_fpga_flow.py +++ b/openfpga_flow/scripts/run_fpga_flow.py @@ -1017,17 +1017,17 @@ def run_command(taskname, logfile, command, exit_if_fail=True): try: output.write(" ".join(command) + "\n") process = subprocess.run( - command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True + command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=False ) - output.write(process.stdout) - output.write(process.stderr) + output.write(process.stdout.decode("cp1252")) + output.write(process.stderr.decode("cp1252")) output.write(str(process.returncode)) if "openfpgashell" in logfile: - filter_openfpga_output(process.stdout) + filter_openfpga_output(process.stdout.decode("cp1252")) if process.returncode: logger.error("%s run failed with returncode %d" % (taskname, process.returncode)) logger.error("command %s" % " ".join(command)) - filter_failed_process_output(process.stderr) + filter_failed_process_output(process.stderr.decode("cp1252")) if exit_if_fail: clean_up_and_exit("Failed to run %s task" % taskname) except Exception: @@ -1036,7 +1036,7 @@ def run_command(taskname, logfile, command, exit_if_fail=True): if exit_if_fail: clean_up_and_exit("Failed to run %s task" % taskname) logger.info("%s is written in file %s" % (taskname, logfile)) - return process.stdout + return process.stdout.decode("cp1252") def filter_openfpga_output(vpr_output):