From 6bc58c03fe403ebacc9ab9decf2ad1a06b96a64e Mon Sep 17 00:00:00 2001 From: Samuel Lopez <85613111+Samuelopez-ansys@users.noreply.github.com> Date: Mon, 13 May 2024 14:29:19 +0200 Subject: [PATCH] REFACTOR: SPISIM linux subprocess (#4665) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Sébastien Morais <146729917+SMoraisAnsys@users.noreply.github.com> --- _unittest_solvers/test_00_analyze.py | 4 ---- pyaedt/generic/spisim.py | 13 +++++++++---- pyaedt/generic/touchstone_parser.py | 7 ++++++- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/_unittest_solvers/test_00_analyze.py b/_unittest_solvers/test_00_analyze.py index 91b665acd5b..d0a45671ce0 100644 --- a/_unittest_solvers/test_00_analyze.py +++ b/_unittest_solvers/test_00_analyze.py @@ -431,7 +431,6 @@ def test_07_export_maxwell_fields(self, m3dtransient): new_setup.props = setup.props new_setup.update() - @pytest.mark.skipif(is_linux and desktop_version == "2024.1", reason="Temporary skip for SPISIM related tests") def test_08_compute_erl(self, circuit_erl): touchstone_file = circuit_erl.export_touchstone() spisim = SpiSim(touchstone_file) @@ -453,7 +452,6 @@ def test_08_compute_erl(self, circuit_erl): erl_data_3 = spisim.compute_erl(specify_through_ports=[1, 2, 3, 4]) assert erl_data_3 - @pytest.mark.skipif(is_linux and desktop_version == "2024.1", reason="Temporary skip for SPISIM related tests") def test_09a_compute_com(self, local_scratch, circuit_com): touchstone_file = circuit_com.export_touchstone() spisim = SpiSim(touchstone_file) @@ -466,7 +464,6 @@ def test_09a_compute_com(self, local_scratch, circuit_com): ) assert com - @pytest.mark.skipif(is_linux and desktop_version == "2024.1", reason="Temporary skip for SPISIM related tests") def test_09b_compute_com(self, local_scratch): com_example_file_folder = os.path.join(local_path, "example_models", test_subfolder, "com_unit_test_sparam") thru_s4p = local_scratch.copyfile(os.path.join(com_example_file_folder, "SerDes_Demo_02_Thru.s4p")) @@ -506,7 +503,6 @@ def test_09b_compute_com(self, local_scratch): ) assert com_0 and com_1 - @pytest.mark.skipif(is_linux and desktop_version == "2024.1", reason="Temporary skip for SPISIM related tests") def test_09c_compute_com(self, local_scratch): com_example_file_folder = Path(local_path) / "example_models" / test_subfolder / "com_unit_test_sparam" thru_s4p = local_scratch.copyfile(com_example_file_folder / "SerDes_Demo_02_Thru.s4p") diff --git a/pyaedt/generic/spisim.py b/pyaedt/generic/spisim.py index d2e2f1c1507..a0a97747d3f 100644 --- a/pyaedt/generic/spisim.py +++ b/pyaedt/generic/spisim.py @@ -59,9 +59,12 @@ def _compute_spisim(self, parameter, out_file="", touchstone_file="", config_fil if touchstone_file != "": cfgCmmd = cfgCmmd + '-i "%s"' % touchstone_file if config_file != "": - cfgCmmd = '-v CFGFILE="%s"' % config_file + if is_linux: + cfgCmmd = "-v CFGFILE=%s" % config_file + else: + cfgCmmd = '-v CFGFILE="%s"' % config_file if out_file: - cfgCmmd += ' -o "%s"' % out_file + cfgCmmd += ', -o "%s"' % out_file command = [spisimExe, parameter, cfgCmmd] # Debug('%s %s' % (cmdList[0], ' '.join(arguments))) # try up to three times to be sure @@ -72,10 +75,12 @@ def _compute_spisim(self, parameter, out_file="", touchstone_file="", config_fil my_env = os.environ.copy() my_env.update(settings.aedt_environment_variables) + if is_linux: # pragma: no cover - if "ANSYSEM_ROOT_PATH" not in my_env: + if "ANSYSEM_ROOT_PATH" not in my_env: # pragma: no cover my_env["ANSYSEM_ROOT_PATH"] = self.desktop_install_dir - command.append("&") + if "SPISIM_OUTPUT_LOG" not in my_env: # pragma: no cover + my_env["SPISIM_OUTPUT_LOG"] = os.path.join(out_file, generate_unique_name("spsim_out") + ".log") with open_file(out_processing, "w") as outfile: subprocess.Popen(command, env=my_env, stdout=outfile, stderr=outfile).wait() # nosec else: diff --git a/pyaedt/generic/touchstone_parser.py b/pyaedt/generic/touchstone_parser.py index 983d164d934..e70e07fc381 100644 --- a/pyaedt/generic/touchstone_parser.py +++ b/pyaedt/generic/touchstone_parser.py @@ -526,9 +526,14 @@ def check_touchstone_files(folder="", passivity=True, causality=True): cmd.append("-checkpassivity") if causality: cmd.append("-checkcausality") + cmd.append(sNpFiles[snpf]) - output_str = str(subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0]) + my_env = os.environ.copy() + p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=my_env) # nosec + output = p.communicate() + output_str = str(output[0]) output_lst = output_str.split("\\r\\n") + if len(output_lst) == 1: output_lst = output_str.splitlines() for line in output_lst: