Skip to content

Commit

Permalink
REFACTOR: SPISIM linux subprocess (#4665)
Browse files Browse the repository at this point in the history
Co-authored-by: Sébastien Morais <[email protected]>
  • Loading branch information
Samuelopez-ansys and SMoraisAnsys authored May 13, 2024
1 parent 14873bc commit 6bc58c0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
4 changes: 0 additions & 4 deletions _unittest_solvers/test_00_analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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"))
Expand Down Expand Up @@ -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")
Expand Down
13 changes: 9 additions & 4 deletions pyaedt/generic/spisim.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
7 changes: 6 additions & 1 deletion pyaedt/generic/touchstone_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 6bc58c0

Please sign in to comment.