From b3fd3cb5265c5e89a6aa1061cf63ee418cbd8526 Mon Sep 17 00:00:00 2001 From: gmalinve <103059376+gmalinve@users.noreply.github.com> Date: Tue, 29 Oct 2024 14:00:27 +0100 Subject: [PATCH] CHORE: remove all ironpython instances (#5340) 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> Co-authored-by: Sebastien Morais --- _unittest/test_22_Circuit_DynamicLink.py | 15 +--- src/ansys/aedt/core/__init__.py | 3 +- src/ansys/aedt/core/application/analysis.py | 7 +- .../aedt/core/application/analysis_3d.py | 7 +- src/ansys/aedt/core/application/design.py | 11 +-- src/ansys/aedt/core/common_rpc.py | 12 +-- src/ansys/aedt/core/desktop.py | 51 ++---------- src/ansys/aedt/core/downloads.py | 42 +--------- src/ansys/aedt/core/generic/configurations.py | 25 ++---- src/ansys/aedt/core/generic/filesystem.py | 11 +-- .../aedt/core/generic/general_methods.py | 59 ++++--------- .../aedt/core/generic/python_optimizers.py | 17 ++-- src/ansys/aedt/core/hfss.py | 4 +- src/ansys/aedt/core/hfss3dlayout.py | 14 ---- .../aedt/core/modeler/advanced_cad/oms.py | 47 ++++++----- .../core/modeler/advanced_cad/stackup_3d.py | 82 +++++++++---------- src/ansys/aedt/core/modeler/cad/object_3d.py | 5 +- src/ansys/aedt/core/modeler/modeler_pcb.py | 5 -- src/ansys/aedt/core/modules/material_lib.py | 4 - src/ansys/aedt/core/modules/solve_setup.py | 20 ++--- src/ansys/aedt/core/q3d.py | 16 ++-- src/ansys/aedt/core/rpc/rpyc_services.py | 30 ++----- .../advanced/farfield_visualization.py | 4 +- .../visualization/post/farfield_exporter.py | 3 +- 24 files changed, 154 insertions(+), 340 deletions(-) diff --git a/_unittest/test_22_Circuit_DynamicLink.py b/_unittest/test_22_Circuit_DynamicLink.py index 32f7dabebb4..b307394f3a0 100644 --- a/_unittest/test_22_Circuit_DynamicLink.py +++ b/_unittest/test_22_Circuit_DynamicLink.py @@ -29,7 +29,6 @@ from ansys.aedt.core import Circuit from ansys.aedt.core import Q2d from ansys.aedt.core import Q3d -from ansys.aedt.core.generic.general_methods import is_ironpython from ansys.aedt.core.generic.settings import is_linux import pytest @@ -95,16 +94,13 @@ def init(self, aedtapp, local_scratch, examples): def test_01_save(self): assert os.path.exists(self.aedtapp.project_path) - @pytest.mark.skipif( - is_ironpython or config.get("skip_circuits", False), reason="Skipped because Desktop is crashing" - ) + @pytest.mark.skipif(config.get("skip_circuits", False), reason="Skipped because Desktop is crashing") def test_02_add_subcircuits_3dlayout(self): layout_design = "layout_cutout" hfss3Dlayout_comp = self.aedtapp.modeler.schematic.add_subcircuit_3dlayout(layout_design) assert hfss3Dlayout_comp.id == 86 assert hfss3Dlayout_comp - @pytest.mark.skipif(is_ironpython, reason="Skipped because Desktop is crashing") @pytest.mark.skipif(config["NonGraphical"] and is_linux, reason="Method not working in Linux and Non graphical.") def test_03_add_subcircuits_hfss_link(self, add_app): pin_names = self.aedtapp.get_source_pin_names(src_design_name, src_project_name, self.src_project_file, 2) @@ -115,12 +111,10 @@ def test_03_add_subcircuits_hfss_link(self, add_app): assert hfss_comp.id == 87 assert hfss_comp.composed_name == "CompInst@uUSB;87;3" - @pytest.mark.skipif(is_ironpython, reason="Skipped because Desktop is crashing") @pytest.mark.skipif(config["NonGraphical"] and is_linux, reason="Method not working in Linux and Non graphical") def test_04_refresh_dynamic_link(self): assert self.aedtapp.modeler.schematic.refresh_dynamic_link("uUSB") - @pytest.mark.skipif(is_ironpython, reason="Skipped because Desktop is crashing") @pytest.mark.skipif(config["NonGraphical"] and is_linux, reason="Method not working in Linux and Non graphical") def test_05_set_sim_option_on_hfss_subcircuit(self): hfss_comp = "CompInst@uUSB;87;3" @@ -128,13 +122,11 @@ def test_05_set_sim_option_on_hfss_subcircuit(self): assert self.aedtapp.modeler.schematic.set_sim_option_on_hfss_subcircuit(hfss_comp, option="interpolate") assert not self.aedtapp.modeler.schematic.set_sim_option_on_hfss_subcircuit(hfss_comp, option="not_good") - @pytest.mark.skipif(is_ironpython, reason="Skipped because AEDT is crashing.") @pytest.mark.skipif(config["NonGraphical"] and is_linux, reason="Method not working in Linux and Non graphical") def test_06_set_sim_solution_on_hfss_subcircuit(self): hfss_comp = "CompInst@uUSB;87;3" assert self.aedtapp.modeler.schematic.set_sim_solution_on_hfss_subcircuit(hfss_comp) - @pytest.mark.skipif(is_ironpython, reason="Skipped because Desktop is crashing") @pytest.mark.skipif(config["NonGraphical"] and is_linux, reason="Method not working in Linux and Non graphical") def test_07_create_page_port_and_interface_port(self): hfss_comp_id = 87 @@ -207,7 +199,6 @@ def test_07_create_page_port_and_interface_port(self): assert "Port_remove" not in self.aedtapp.excitations - @pytest.mark.skipif(is_ironpython, reason="Skipped because Desktop is crashing") @pytest.mark.skipif(config["NonGraphical"] and is_linux, reason="Method not working in Linux and Non graphical") def test_08_assign_excitations(self): filepath = os.path.join(local_path, "example_models", test_subfloder, "frequency_dependent_source.fds") @@ -233,7 +224,6 @@ def test_09_setup(self): LNA_setup.props["SweepDefinition"]["Data"] = " ".join(sweep_list) assert LNA_setup.update() - @pytest.mark.skipif(is_ironpython, reason="Skipped because Desktop is crashing") @pytest.mark.skipif(config["NonGraphical"] and is_linux, reason="Method not working in Linux and Non graphical") def test_10_q2d_link(self, add_app): self.aedtapp.insert_design("test_link") @@ -244,7 +234,6 @@ def test_10_q2d_link(self, add_app): assert c1.parameters["Length"] == "25mm" assert c1.parameters["r1"] == "0.3mm" - @pytest.mark.skipif(is_ironpython, reason="Skipped because Desktop is crashing") @pytest.mark.skipif(config["NonGraphical"] and is_linux, reason="Method not working in Linux and Non graphical") def test_10_q3d_link(self, add_app): q3d = add_app(application=Q3d, project_name=self.q3d, just_open=True) @@ -255,7 +244,6 @@ def test_10_q3d_link(self, add_app): assert q3d_comp assert len(q3d_comp.pins) == 4 - @pytest.mark.skipif(is_ironpython, reason="Skipped because Desktop is crashing") @pytest.mark.skipif(config["NonGraphical"] and is_linux, reason="Method not working in Linux and Non graphical") def test_10_hfss_link(self, add_app): hfss = add_app(project_name=self.q3d, just_open=True) @@ -268,7 +256,6 @@ def test_10_hfss_link(self, add_app): hfss2, solution_name="Setup2 : Sweep", tline_port="1" ) - @pytest.mark.skipif(is_ironpython, reason="Skipped because Desktop is crashing") @pytest.mark.skipif(config["NonGraphical"] and is_linux, reason="Method not working in Linux and Non graphical") def test_11_siwave_link(self): model = os.path.join(local_path, "example_models", test_subfloder, "siwave_syz.siw") diff --git a/src/ansys/aedt/core/__init__.py b/src/ansys/aedt/core/__init__.py index a7d05904f3d..418d5dff37d 100644 --- a/src/ansys/aedt/core/__init__.py +++ b/src/ansys/aedt/core/__init__.py @@ -74,7 +74,7 @@ def custom_show_warning(message, category, filename, lineno, file=None, line=Non # isort: on -if not ("IronPython" in sys.version or ".NETFramework" in sys.version): # pragma: no cover +if not (".NETFramework" in sys.version): # pragma: no cover import ansys.aedt.core.downloads as downloads from ansys.aedt.core.edb import Edb # nosec from ansys.aedt.core.edb import Siwave # nosec @@ -105,7 +105,6 @@ def custom_show_warning(message, category, filename, lineno, file=None, line=Non from ansys.aedt.core.generic.general_methods import generate_unique_name from ansys.aedt.core.generic.general_methods import generate_unique_project_name from ansys.aedt.core.generic.general_methods import inside_desktop -from ansys.aedt.core.generic.general_methods import is_ironpython from ansys.aedt.core.generic.general_methods import is_linux from ansys.aedt.core.generic.general_methods import is_windows from ansys.aedt.core.generic.general_methods import online_help diff --git a/src/ansys/aedt/core/application/analysis.py b/src/ansys/aedt/core/application/analysis.py index b272ee1e297..2ecb6c72066 100644 --- a/src/ansys/aedt/core/application/analysis.py +++ b/src/ansys/aedt/core/application/analysis.py @@ -34,6 +34,7 @@ import os import re import shutil +import subprocess # nosec import tempfile import time @@ -49,7 +50,6 @@ from ansys.aedt.core.generic.constants import VIEW from ansys.aedt.core.generic.general_methods import filter_tuple from ansys.aedt.core.generic.general_methods import generate_unique_name -from ansys.aedt.core.generic.general_methods import is_ironpython from ansys.aedt.core.generic.general_methods import is_linux from ansys.aedt.core.generic.general_methods import is_windows from ansys.aedt.core.generic.general_methods import open_file @@ -69,11 +69,6 @@ from ansys.aedt.core.modules.solve_setup import SetupSBR from ansys.aedt.core.modules.solve_sweeps import SetupProps -if is_linux and is_ironpython: - import subprocessdotnet as subprocess # nosec -else: - import subprocess # nosec - class Analysis(Design, object): """Contains all common analysis functions. diff --git a/src/ansys/aedt/core/application/analysis_3d.py b/src/ansys/aedt/core/application/analysis_3d.py index 991ffbee012..71f71d031e5 100644 --- a/src/ansys/aedt/core/application/analysis_3d.py +++ b/src/ansys/aedt/core/application/analysis_3d.py @@ -30,7 +30,6 @@ from ansys.aedt.core.generic.configurations import Configurations from ansys.aedt.core.generic.constants import unit_converter from ansys.aedt.core.generic.general_methods import generate_unique_name -from ansys.aedt.core.generic.general_methods import is_ironpython from ansys.aedt.core.generic.general_methods import open_file from ansys.aedt.core.generic.general_methods import pyaedt_function_handler from ansys.aedt.core.generic.settings import settings @@ -283,9 +282,7 @@ def plot( :class:`ansys.aedt.core.generic.plot.ModelPlotter` Model Object. """ - if is_ironpython: - self.logger.warning("Plot is available only on CPython") - elif self._aedt_version < "2021.2": + if self._aedt_version < "2021.2": self.logger.warning("Plot is supported from AEDT 2021 R2.") else: return self.post.plot_model_obj( @@ -1175,7 +1172,7 @@ def identify_touching_conductors(self, assignment=None): dict """ - if is_ironpython and settings.aedt_version < "2023.2": # pragma: no cover + if settings.aedt_version < "2023.2": # pragma: no cover self.logger.error("This method requires CPython and PyVista.") return {} if settings.aedt_version >= "2023.2" and self.design_type == "HFSS": # pragma: no cover diff --git a/src/ansys/aedt/core/application/design.py b/src/ansys/aedt/core/application/design.py index 358f8715a26..b3fbd0acd09 100644 --- a/src/ansys/aedt/core/application/design.py +++ b/src/ansys/aedt/core/application/design.py @@ -66,7 +66,6 @@ from ansys.aedt.core.generic.general_methods import check_and_download_file from ansys.aedt.core.generic.general_methods import generate_unique_name from ansys.aedt.core.generic.general_methods import inner_project_settings -from ansys.aedt.core.generic.general_methods import is_ironpython from ansys.aedt.core.generic.general_methods import is_project_locked from ansys.aedt.core.generic.general_methods import is_windows from ansys.aedt.core.generic.general_methods import open_file @@ -240,8 +239,7 @@ def __init__( self._project_path = None self.__t = None if ( - not is_ironpython - and project_name + project_name and os.path.exists(project_name) and (os.path.splitext(project_name)[1] == ".aedt" or os.path.splitext(project_name)[1] == ".a3dcomp") ): @@ -301,7 +299,7 @@ def __init__( self._logger.odesign = self.odesign AedtObjects.__init__(self, self._desktop_class, self.oproject, self.odesign, is_inherithed=True) self.logger.info("Aedt Objects correctly read") - if not self.__t and not settings.lazy_load and not is_ironpython and os.path.exists(self.project_file): + if not self.__t and not settings.lazy_load and os.path.exists(self.project_file): self.__t = threading.Thread(target=load_aedt_thread, args=(self.project_file,), daemon=True) self.__t.start() self._variable_manager = VariableManager(self) @@ -2660,7 +2658,7 @@ def load_project(self, file_name, design=None, close_active=False, set_active=Fa @pyaedt_function_handler() def _close_edb(self): - if self.design_type == "HFSS 3D Layout Design" and not is_ironpython: # pragma: no cover + if self.design_type == "HFSS 3D Layout Design": # pragma: no cover if self.modeler and self.modeler._edb: self.modeler._edb.close_edb() @@ -3292,8 +3290,7 @@ def close_project(self, name=None, save=True): self._logger = self._global_logger self.odesktop.CloseProject(name) if name == legacy_name: - if not is_ironpython: - self._init_variables() + self._init_variables() self._oproject = None self._odesign = None self.logger.odesign = None diff --git a/src/ansys/aedt/core/common_rpc.py b/src/ansys/aedt/core/common_rpc.py index ade32b0ca37..386c3b5e1a6 100644 --- a/src/ansys/aedt/core/common_rpc.py +++ b/src/ansys/aedt/core/common_rpc.py @@ -30,7 +30,6 @@ from ansys.aedt.core.aedt_logger import pyaedt_logger as logger from ansys.aedt.core.generic.aedt_versions import aedt_versions -from ansys.aedt.core.generic.general_methods import is_ironpython from ansys.aedt.core.generic.settings import settings # import sys @@ -38,13 +37,10 @@ from ansys.aedt.core.rpc.rpyc_services import GlobalService from ansys.aedt.core.rpc.rpyc_services import ServiceManager from ansys.aedt.core.rpc.rpyc_services import check_port - -if not is_ironpython: - import rpyc - from rpyc.core import consts - from rpyc.utils.server import OneShotServer - from rpyc.utils.server import ThreadedServer - +import rpyc +from rpyc.core import consts +from rpyc.utils.server import OneShotServer +from rpyc.utils.server import ThreadedServer # Maximum Stream message size. Set to 256MB consts.STREAM_CHUNK = 256000000 diff --git a/src/ansys/aedt/core/desktop.py b/src/ansys/aedt/core/desktop.py index 3dac79dcca7..5693fcfb9e0 100644 --- a/src/ansys/aedt/core/desktop.py +++ b/src/ansys/aedt/core/desktop.py @@ -50,17 +50,13 @@ from ansys.aedt.core.aedt_logger import AedtLogger from ansys.aedt.core.aedt_logger import pyaedt_logger from ansys.aedt.core.generic.general_methods import generate_unique_name -from ansys.aedt.core.generic.general_methods import is_ironpython from ansys.aedt.core.generic.general_methods import is_linux from ansys.aedt.core.generic.general_methods import is_windows if is_linux: os.environ["ANS_NODEPCHECK"] = str(1) -if is_linux and is_ironpython: # pragma: no cover - import subprocessdotnet as subprocess -else: - import subprocess +import subprocess from ansys.aedt.core import __version__ from ansys.aedt.core.generic.aedt_versions import aedt_versions @@ -71,7 +67,6 @@ from ansys.aedt.core.generic.general_methods import get_string_version from ansys.aedt.core.generic.general_methods import grpc_active_sessions from ansys.aedt.core.generic.general_methods import inside_desktop -from ansys.aedt.core.generic.general_methods import is_ironpython from ansys.aedt.core.generic.general_methods import open_file from ansys.aedt.core.generic.general_methods import pyaedt_function_handler from ansys.aedt.core.generic.settings import settings @@ -296,7 +291,7 @@ def _close_aedt_application(desktop_class, close_desktop, pid, is_grpc_api): ``True`` when successful, ``False`` when failed. """ - if settings.remote_rpc_session or (settings.aedt_version >= "2022.2" and is_grpc_api and not is_ironpython): + if settings.remote_rpc_session or (settings.aedt_version >= "2022.2" and is_grpc_api): if close_desktop and desktop_class.parent_desktop_id: # pragma: no cover pyaedt_logger.error("A child desktop session is linked to this session.") pyaedt_logger.error("Multiple desktop sessions must be released in reverse order.") @@ -340,7 +335,7 @@ def _close_aedt_application(desktop_class, close_desktop, pid, is_grpc_api): pyaedt_logger.warning( "Something went wrong releasing AEDT. Exception in `_main.COMUtil.ReleaseCOMObjectScope`." ) - if not settings.remote_rpc_session and not is_ironpython and close_desktop: # pragma: no cover + if not settings.remote_rpc_session and close_desktop: # pragma: no cover timeout = 10 while pid in active_sessions(): time.sleep(1) @@ -579,10 +574,10 @@ def __init__( student_version_flag, version_key, version = self._assert_version(version, student_version) # start the AEDT opening decision tree - # starting_mode can be one of these: "grpc", "com", "ironpython", "console_in", "console_out" + # starting_mode can be one of these: "grpc", "com", "console_in", "console_out" if "oDesktop" in dir(sys.modules["__main__"]): # pragma: no cover # we are inside the AEDT Ironpython console - pyaedt_logger.logger.info("Iropnpython session with embedded oDesktop") + pyaedt_logger.logger.info("Ironpython session with embedded oDesktop") starting_mode = "console_in" elif is_linux: starting_mode = "grpc" @@ -590,9 +585,7 @@ def __init__( starting_mode = "grpc" elif settings.remote_rpc_session: starting_mode = "grpc" - elif is_ironpython: - starting_mode = "ironpython" - elif aedt_process_id and not new_desktop and not is_ironpython: # pragma: no cover + elif aedt_process_id and not new_desktop: # pragma: no cover # connecting to an existing session has the precedence over use_grpc_api user preference sessions = active_sessions( version=version, student_version=student_version_flag, non_graphical=non_graphical @@ -642,10 +635,7 @@ def __init__( else: settings.aedt_version = version_key - if starting_mode == "ironpython": # pragma no cover - self._logger.info("Launching PyAEDT with IronPython.") - self._init_ironpython(non_graphical, new_desktop, version) - elif starting_mode == "com": # pragma no cover + if starting_mode == "com": # pragma no cover self._logger.info("Launching PyAEDT with CPython and PythonNET.") self._init_dotnet( non_graphical, @@ -680,8 +670,6 @@ def __init__( self.aedt_version_id = self.odesktop.GetVersion()[0:6] - if is_ironpython: # pragma no cover - sys.path.append(os.path.join(settings.aedt_install_dir, "common", "commonfiles", "IronPython", "DLLs")) if "GetGrpcServerPort" in dir(self.odesktop): self.port = self.odesktop.GetGrpcServerPort() # save the current desktop session in the database @@ -698,7 +686,7 @@ def __exit__(self, ex_type, ex_value, ex_traceback): # pragma no cover # Write the trace stack to the log file if an exception occurred in the main script. if ex_type: err = self._exception(ex_value, ex_traceback) - if self.close_on_exit or not is_ironpython: + if self.close_on_exit: self.release_desktop(close_projects=self.close_on_exit, close_on_exit=self.close_on_exit) self.__closed = True @@ -898,28 +886,6 @@ def _assert_version(self, specified_version, student_version): return student_version, specified_version, version - def _init_ironpython(self, non_graphical, new_aedt_session, version): # pragma no cover - from ansys.aedt.core.generic.clr_module import _clr - - base_path = settings.aedt_install_dir - sys.path.append(base_path) - sys.path.append(os.path.join(base_path, "PythonFiles", "DesktopPlugin")) - _clr.AddReference("Ansys.Ansoft.CoreCOMScripting") - AnsoftCOMUtil = __import__("Ansys.Ansoft.CoreCOMScripting") - self.COMUtil = AnsoftCOMUtil.Ansoft.CoreCOMScripting.Util.COMUtil - StandalonePyScriptWrapper = AnsoftCOMUtil.Ansoft.CoreCOMScripting.COM.StandalonePyScriptWrapper - if non_graphical or new_aedt_session: - # forcing new thread to start in non-graphical - oAnsoftApp = StandalonePyScriptWrapper.CreateObjectNew(non_graphical) - else: - oAnsoftApp = StandalonePyScriptWrapper.CreateObject(version) - self.odesktop = oAnsoftApp.GetAppDesktop() - self.isoutsideDesktop = True - sys.path.append(os.path.join(base_path, "common", "commonfiles", "IronPython", "DLLs")) - self.is_grpc_api = False - - return True - @staticmethod def _run_student(): # pragma: no cover DETACHED_PROCESS = 0x00000008 @@ -1049,7 +1015,6 @@ def _initialize( self.grpc_plugin = AEDT(os.environ["DesktopPluginPyAEDT"]) oapp = self.grpc_plugin.CreateAedtApplication(machine, port, non_graphical, new_session) if oapp: - self.isoutsideDesktop = True self.aedt_process_id = self.odesktop.GetProcessID() return True diff --git a/src/ansys/aedt/core/downloads.py b/src/ansys/aedt/core/downloads.py index 27a2f7af2dd..9929387b0f3 100644 --- a/src/ansys/aedt/core/downloads.py +++ b/src/ansys/aedt/core/downloads.py @@ -27,19 +27,13 @@ import os import shutil import tempfile +import urllib.request import zipfile -from ansys.aedt.core.generic.aedt_versions import aedt_versions -from ansys.aedt.core.generic.general_methods import is_ironpython from ansys.aedt.core.generic.general_methods import is_linux from ansys.aedt.core.generic.general_methods import pyaedt_function_handler from ansys.aedt.core.generic.general_methods import settings -if is_ironpython: - import urllib -else: - import urllib.request - tmpfold = tempfile.gettempdir() EXAMPLE_REPO = "https://github.com/ansys/example-data/raw/master/" EXAMPLES_PATH = os.path.join(tmpfold, "PyAEDTExamples") @@ -74,8 +68,7 @@ def _retrieve_file(url, name, directory, destination=None, local_paths=None): local_paths.append(local_path_no_zip) # grab the correct url retriever - if not is_ironpython: - urlretrieve = urllib.request.urlretrieve + urlretrieve = urllib.request.urlretrieve destination_dir = os.path.join(destination, directory) if not os.path.isdir(destination_dir): os.makedirs(destination_dir) @@ -83,35 +76,6 @@ def _retrieve_file(url, name, directory, destination=None, local_paths=None): if is_linux: command = f"wget {url} -O {local_path}" os.system(command) - elif is_ironpython: - versions = aedt_versions.list_installed_ansysem - if versions: - cpython = os.listdir(os.path.join(os.getenv(versions[0]), "commonfiles", "CPython")) - command = ( - '"' - + os.path.join( - os.getenv(versions[0]), - "commonfiles", - "CPython", - cpython[0], - "winx64", - "Release", - "python", - "python.exe", - ) - + '"' - ) - commandargs = os.path.join(os.path.dirname(local_path), "download.py") - command += ' "' + commandargs + '"' - with open(os.path.join(os.path.dirname(local_path), "download.py"), "w") as f: - f.write("import urllib.request\n") - f.write("urlretrieve = urllib.request.urlretrieve\n") - f.write("import urllib.request\n") - f.write(f'url = r"{url}"\n') - f.write(f'local_path = r"{local_path}"\n') - f.write("urlretrieve(url, local_path)\n") - print(command) - os.system(command) else: _, resp = urlretrieve(url, local_path) local_paths.append(local_path) @@ -136,8 +100,6 @@ def _retrieve_folder(url, directory, destination=None, local_paths=None): # Ensure that "/" is parsed as a path delimiter. local_path = os.path.join(*local_path.split("/")) - if is_ironpython: - return False _get_dir = _get_file_url(directory) with urllib.request.urlopen(_get_dir) as response: # nosec data = response.read().decode("utf-8").split("\n") diff --git a/src/ansys/aedt/core/generic/configurations.py b/src/ansys/aedt/core/generic/configurations.py index 99e7fdeb69d..da649c10b74 100644 --- a/src/ansys/aedt/core/generic/configurations.py +++ b/src/ansys/aedt/core/generic/configurations.py @@ -35,7 +35,6 @@ from ansys.aedt.core.generic.general_methods import GrpcApiError from ansys.aedt.core.generic.general_methods import generate_unique_folder_name from ansys.aedt.core.generic.general_methods import generate_unique_name -from ansys.aedt.core.generic.general_methods import is_ironpython from ansys.aedt.core.generic.general_methods import open_file from ansys.aedt.core.generic.general_methods import pyaedt_function_handler from ansys.aedt.core.generic.general_methods import read_configuration_file @@ -54,10 +53,8 @@ from ansys.aedt.core.modules.mesh import MeshOperation from ansys.aedt.core.modules.mesh_icepak import MeshRegion from ansys.aedt.core.modules.mesh_icepak import SubRegion - -if not is_ironpython: - from jsonschema import exceptions - from jsonschema import validate +from jsonschema import exceptions +from jsonschema import validate def _find_datasets(d, out_list): @@ -1074,17 +1071,13 @@ def validate(self, config): self._app.logger.warning("Incorrect data type.") return False - if is_ironpython: - self._app.logger.warning("Iron Python: Unable to validate json Schema.") - else: - try: - validate(instance=config_data, schema=self.schema) - return True - except exceptions.ValidationError as e: - self._app.logger.warning("Configuration is invalid.") - self._app.logger.warning("Validation error:" + e.message) - return False - return True + try: + validate(instance=config_data, schema=self.schema) + return True + except exceptions.ValidationError as e: # pragma : no cover + self._app.logger.warning("Configuration is invalid.") + self._app.logger.warning("Validation error:" + e.message) + return False @pyaedt_function_handler() def import_config(self, config_file, *args): diff --git a/src/ansys/aedt/core/generic/filesystem.py b/src/ansys/aedt/core/generic/filesystem.py index d4e434b4891..534dcc2bc63 100644 --- a/src/ansys/aedt/core/generic/filesystem.py +++ b/src/ansys/aedt/core/generic/filesystem.py @@ -42,16 +42,9 @@ def search_files(dirname, pattern="*"): ------- list """ - from ansys.aedt.core.generic.general_methods import is_ironpython + import pathlib - if is_ironpython: - import glob - - return list(glob.glob(os.path.join(dirname, pattern))) - else: - import pathlib - - return [os.path.abspath(i) for i in pathlib.Path(dirname).glob(pattern)] + return [os.path.abspath(i) for i in pathlib.Path(dirname).glob(pattern)] def my_location(): diff --git a/src/ansys/aedt/core/generic/general_methods.py b/src/ansys/aedt/core/generic/general_methods.py index 9fc61806e99..dc7d593af7a 100644 --- a/src/ansys/aedt/core/generic/general_methods.py +++ b/src/ansys/aedt/core/generic/general_methods.py @@ -49,14 +49,11 @@ from ansys.aedt.core.generic.constants import CSS4_COLORS from ansys.aedt.core.generic.settings import inner_project_settings # noqa: F401 from ansys.aedt.core.generic.settings import settings +import psutil -is_ironpython = "IronPython" in sys.version or ".NETFramework" in sys.version is_linux = os.name == "posix" is_windows = not is_linux -inside_desktop = True if is_ironpython and "4.0.30319.42000" in sys.version else False - -if not is_ironpython: - import psutil +inside_desktop = True if "4.0.30319.42000" in sys.version else False inclusion_list = [ "CreateVia", @@ -425,8 +422,6 @@ def open_file(file_path, file_options="r", encoding=None, override_existing=True object Opened file. """ - if is_ironpython: - return open(file_path, file_options) file_path = str(file_path) file_path = file_path.replace("\\", "/") if file_path[0] != "\\" else file_path @@ -732,16 +727,12 @@ def generate_unique_name(root_name, suffix="", n=6): Newly generated name. """ alphabet = string.ascii_uppercase + string.digits - if is_ironpython: - import random - uName = "".join(random.choice(alphabet) for _ in range(n)) # nosec B311 - else: - import secrets + import secrets - uName = "".join(secrets.choice(alphabet) for _ in range(n)) + name = "".join(secrets.choice(alphabet) for _ in range(n)) - unique_name = root_name + "_" + uName + unique_name = root_name + "_" + name if suffix: unique_name += "_" + suffix return unique_name @@ -1180,10 +1171,7 @@ def write_csv(output_file, list_data, delimiter=",", quote_char="|", quoting=csv bool ``True`` when successful, ``False`` when failed. """ - if is_ironpython: - f = open(output_file, "wb") - else: - f = open(output_file, "w", newline="") + f = open(output_file, "w", newline="") writer = csv.writer(f, delimiter=delimiter, quotechar=quote_char, quoting=quoting) for data in list_data: writer.writerow(data) @@ -1344,21 +1332,11 @@ def _dict_toml(d): def _create_json_file(json_dict, full_json_path): if not os.path.exists(os.path.dirname(full_json_path)): os.makedirs(os.path.dirname(full_json_path)) - if not is_ironpython: - with open_file(full_json_path, "w") as fp: - json.dump(json_dict, fp, indent=4) - else: - temp_path = full_json_path.replace(".json", "_temp.json") - with open_file(temp_path, "w") as fp: - json.dump(json_dict, fp, indent=4) - with open_file(temp_path, "r") as file: - filedata = file.read() - filedata = filedata.replace("True", "true") - filedata = filedata.replace("False", "false") - with open_file(full_json_path, "w") as file: - file.write(filedata) - os.remove(temp_path) + + with open_file(full_json_path, "w") as fp: + json.dump(json_dict, fp, indent=4) settings.logger.info(f"{full_json_path} correctly created.") + return True @@ -2120,15 +2098,12 @@ def _uname(name=None): """ alphabet = string.ascii_uppercase + string.digits - if is_ironpython: - import random - unique_name = "".join(random.sample(alphabet, 6)) # nosec B311 - else: - import secrets + import secrets + + generator = secrets.SystemRandom() + unique_name = "".join(secrets.SystemRandom.sample(generator, alphabet, 6)) - generator = secrets.SystemRandom() - unique_name = "".join(secrets.SystemRandom.sample(generator, alphabet, 6)) if name: return name + unique_name else: @@ -2232,10 +2207,8 @@ def install_with_pip(package_name, package_path=None, upgrade=False, uninstall=F uninstall : bool, optional Whether to install the package or uninstall the package. """ - if is_linux and is_ironpython: - import subprocessdotnet as subprocess # nosec B404 - else: - import subprocess # nosec B404 + import subprocess # nosec B404 + executable = f'"{sys.executable}"' if is_windows else sys.executable commands = [] diff --git a/src/ansys/aedt/core/generic/python_optimizers.py b/src/ansys/aedt/core/generic/python_optimizers.py index 7943d6b2e75..a3e9e36a011 100644 --- a/src/ansys/aedt/core/generic/python_optimizers.py +++ b/src/ansys/aedt/core/generic/python_optimizers.py @@ -26,16 +26,13 @@ import threading import warnings -from ansys.aedt.core.generic.general_methods import is_ironpython - -if not is_ironpython: - try: - import numpy as np - except ImportError: - warnings.warn( - "The NumPy module is required to run some functionalities of PostProcess.\n" - "Install with \n\npip install numpy\n\nRequires CPython." - ) +try: + import numpy as np +except ImportError: # pragma: no cover + warnings.warn( + "The NumPy module is required to run some functionalities of PostProcess.\n" + "Install with \n\npip install numpy\n\nRequires CPython." + ) class ThreadTrace(threading.Thread): diff --git a/src/ansys/aedt/core/hfss.py b/src/ansys/aedt/core/hfss.py index f0f86cff9e1..fe4c3bf4fa4 100644 --- a/src/ansys/aedt/core/hfss.py +++ b/src/ansys/aedt/core/hfss.py @@ -5853,7 +5853,7 @@ def get_antenna_ffd_solution_data( Returns ------- - :class:`ansys.aedt.core.generic.farfield_visualization.FfdSolutionDataExporter` + :class:`ansys.aedt.core.visualization.post.farfield_exporter.FfdSolutionDataExporter` SolutionData object. """ warnings.warn("Use :func:`get_antenna_data` method instead.", DeprecationWarning) @@ -5913,7 +5913,7 @@ def get_antenna_data( Returns ------- - :class:`ansys.aedt.core.generic.farfield_visualization.FfdSolutionDataExporter` + :class:`ansys.aedt.core.visualization.advanced.farfield_visualization.FfdSolutionDataExporter` SolutionData object. Examples diff --git a/src/ansys/aedt/core/hfss3dlayout.py b/src/ansys/aedt/core/hfss3dlayout.py index 6afbc297e02..bd044ca9ed7 100644 --- a/src/ansys/aedt/core/hfss3dlayout.py +++ b/src/ansys/aedt/core/hfss3dlayout.py @@ -34,7 +34,6 @@ from ansys.aedt.core.application.analysis_3d_layout import FieldAnalysis3DLayout from ansys.aedt.core.application.analysis_hf import ScatteringMethods from ansys.aedt.core.generic.general_methods import generate_unique_name -from ansys.aedt.core.generic.general_methods import is_ironpython from ansys.aedt.core.generic.general_methods import open_file from ansys.aedt.core.generic.general_methods import parse_excitation_file from ansys.aedt.core.generic.general_methods import pyaedt_function_handler @@ -2326,10 +2325,6 @@ def get_dcir_solution_data(self, setup, show="RL", category="Loop_Resistance"): ------- from ansys.aedt.core.modules.solutions.SolutionData """ - - if is_ironpython: # pragma: no cover - self._logger.error("Function is only supported in CPython.") - return False all_categories = self.post.available_quantities_categories(context=show, is_siwave_dc=True) if category not in all_categories: return False # pragma: no cover @@ -2353,9 +2348,6 @@ def get_dcir_element_data_loop_resistance(self, setup): ------- pandas.Dataframe """ - if is_ironpython: # pragma: no cover - self.logger.error("Method not supported in IronPython.") - return False import pandas as pd solution_data = self.get_dcir_solution_data(setup=setup, show="RL", category="Loop Resistance") @@ -2395,9 +2387,6 @@ def get_dcir_element_data_current_source(self, setup): ------- pandas.Dataframe """ - if is_ironpython: # pragma: no cover - self.logger.error("Method not supported in IronPython.") - return False import pandas as pd solution_data = self.get_dcir_solution_data(setup=setup, show="Sources", category="Voltage") @@ -2431,9 +2420,6 @@ def get_dcir_element_data_via(self, setup): ------- pandas.Dataframe """ - if is_ironpython: - self.logger.error("Method not supported in IronPython.") - return False import pandas as pd cates = ["X", "Y", "Current", "Resistance", "IR Drop", "Power"] diff --git a/src/ansys/aedt/core/modeler/advanced_cad/oms.py b/src/ansys/aedt/core/modeler/advanced_cad/oms.py index bfa7e4de661..045bc42630d 100644 --- a/src/ansys/aedt/core/modeler/advanced_cad/oms.py +++ b/src/ansys/aedt/core/modeler/advanced_cad/oms.py @@ -25,31 +25,36 @@ import os import warnings -from ansys.aedt.core.generic.general_methods import is_ironpython from ansys.aedt.core.generic.general_methods import pyaedt_function_handler from ansys.aedt.core.generic.general_methods import settings logger = settings.logger -if not is_ironpython: - try: - import numpy as np - - except ImportError: - warnings.warn("numpy package is needed") - - try: - import pyvista as pv - import vtk - except ImportError: - warnings.warn("pyvista package is needed") - - try: - import osmnx as ox - import srtm - import utm - - except ImportError: - warnings.warn("OpenStreetMap Reader requires utm, osmnx and srtm extra packages") + +try: + import numpy as np +except ImportError: # pragma: no cover + warnings.warn( + "The NumPy module is required to use the OpenStreetMap Reader.\n" "Install with \n\npip install numpy" + ) + +try: + import pyvista as pv + import vtk +except ImportError: # pragma: no cover + warnings.warn( + "The PyVista module is required to use the OpenStreetMap Reader.\n" "Install with \n\npip install pyvista" + ) + +try: + import osmnx as ox + import srtm + import utm + +except ImportError: # pragma: no cover + warnings.warn( + "OpenStreetMap Reader requires utm, osmnx and srtm extra packages.\n" + "Install with \n\npip install utm osmnx srtm" + ) class BuildingsPrep(object): diff --git a/src/ansys/aedt/core/modeler/advanced_cad/stackup_3d.py b/src/ansys/aedt/core/modeler/advanced_cad/stackup_3d.py index f6d3e2335d5..cd7a7ba2845 100644 --- a/src/ansys/aedt/core/modeler/advanced_cad/stackup_3d.py +++ b/src/ansys/aedt/core/modeler/advanced_cad/stackup_3d.py @@ -23,23 +23,30 @@ # SOFTWARE. import os - -from ansys.aedt.core.generic.general_methods import is_ironpython - -if not is_ironpython: - try: - import joblib - except ImportError: - pass - try: - import numpy as np - except ImportError: - pass +import warnings + +try: + import joblib +except ImportError: # pragma: no cover + joblib = None + warnings.warn( + "The Joblib module is required to use functionalities provided by the module " + "ansys.aedt.core.modeler.advanced_cad.stackup_3d.\n" + "Install with \n\npip install joblib" + ) +try: + import numpy as np +except ImportError: # pragma: no cover + np = None + warnings.warn( + "The Numpy module is required to use functionalities provided by the module " + "ansys.aedt.core.modeler.advanced_cad.stackup_3d.\n" + "Install with \n\npip install numpy" + ) from ansys.aedt.core import constants from ansys.aedt.core import pyaedt_path from ansys.aedt.core.generic.general_methods import generate_unique_name -from ansys.aedt.core.generic.general_methods import is_ironpython from ansys.aedt.core.generic.general_methods import pyaedt_function_handler from ansys.aedt.core.modules.material_lib import Material @@ -3479,32 +3486,25 @@ def __init__( self.predict_length() def predict_length(self): - if not is_ironpython: - try: - joblib - except NameError: # pragma: no cover - raise ImportError("joblib package is needed to run ML.") - training_file = None - if 1e9 >= self.frequency.numeric_value >= 1e8: - training_file = os.path.join(pyaedt_path, "misc", "patch_svr_model_100MHz_1GHz.joblib") - elif 1e10 >= self.frequency.numeric_value > 1e9: - training_file = os.path.join(pyaedt_path, "misc", "patch_svr_model_1GHz_10GHz.joblib") - else: - self.application.logger.error( - "This ML algorithm can only predict patch antennas from 100 MHz to 10 GHz." - ) - if training_file: - model = joblib.load(training_file) - list_for_array = [ - [ - self.frequency.numeric_value, - self.width.numeric_value, - self._permittivity.numeric_value, - self.dielectric_layer.thickness.numeric_value, - ] - ] - array_for_prediction = np.array(list_for_array, dtype=np.float32) - length = model.predict(array_for_prediction)[0] - self.length.expression = self.application.modeler._arg_with_dim(length) + if joblib is None: # pragma: no cover + raise ImportError("Package Joblib is required to run ML.") + training_file = None + if 1e9 >= self.frequency.numeric_value >= 1e8: + training_file = os.path.join(pyaedt_path, "misc", "patch_svr_model_100MHz_1GHz.joblib") + elif 1e10 >= self.frequency.numeric_value > 1e9: + training_file = os.path.join(pyaedt_path, "misc", "patch_svr_model_1GHz_10GHz.joblib") else: # pragma: no cover - self.application.logger.warning("Machine learning algorithm aren't covered in IronPython.") + self.application.logger.error("This ML algorithm can only predict patch antennas from 100 MHz to 10 GHz.") + if training_file: + model = joblib.load(training_file) + list_for_array = [ + [ + self.frequency.numeric_value, + self.width.numeric_value, + self._permittivity.numeric_value, + self.dielectric_layer.thickness.numeric_value, + ] + ] + array_for_prediction = np.array(list_for_array, dtype=np.float32) + length = model.predict(array_for_prediction)[0] + self.length.expression = self.application.modeler._arg_with_dim(length) diff --git a/src/ansys/aedt/core/modeler/cad/object_3d.py b/src/ansys/aedt/core/modeler/cad/object_3d.py index f438686c0ee..0301c40392f 100644 --- a/src/ansys/aedt/core/modeler/cad/object_3d.py +++ b/src/ansys/aedt/core/modeler/cad/object_3d.py @@ -41,7 +41,6 @@ from ansys.aedt.core.generic.general_methods import _to_boolean from ansys.aedt.core.generic.general_methods import _uname from ansys.aedt.core.generic.general_methods import clamp -from ansys.aedt.core.generic.general_methods import is_ironpython from ansys.aedt.core.generic.general_methods import open_file from ansys.aedt.core.generic.general_methods import pyaedt_function_handler from ansys.aedt.core.generic.general_methods import rgb_color_codes @@ -273,7 +272,7 @@ def plot(self, show=True): ----- Works from AEDT 2021.2 in CPython only. PyVista has to be installed. """ - if not is_ironpython and self._primitives._app._aedt_version >= "2021.2": + if self._primitives._app._aedt_version >= "2021.2": return self._primitives._app.post.plot_model_obj( objects=[self.name], plot_as_separate_objects=True, @@ -301,7 +300,7 @@ def export_image(self, output_file=None): str File path. """ - if not is_ironpython and self._primitives._app._aedt_version >= "2021.2": + if self._primitives._app._aedt_version >= "2021.2": if not output_file: output_file = os.path.join(self._primitives._app.working_directory, self.name + ".png") model_obj = self._primitives._app.post.plot_model_obj( diff --git a/src/ansys/aedt/core/modeler/modeler_pcb.py b/src/ansys/aedt/core/modeler/modeler_pcb.py index 4691eda6b11..6a96d2d64dc 100644 --- a/src/ansys/aedt/core/modeler/modeler_pcb.py +++ b/src/ansys/aedt/core/modeler/modeler_pcb.py @@ -30,7 +30,6 @@ from ansys.aedt.core.generic.general_methods import generate_unique_name from ansys.aedt.core.generic.general_methods import get_filename_without_extension from ansys.aedt.core.generic.general_methods import inside_desktop -from ansys.aedt.core.generic.general_methods import is_ironpython from ansys.aedt.core.generic.general_methods import open_file from ansys.aedt.core.generic.general_methods import pyaedt_function_handler from ansys.aedt.core.generic.settings import settings @@ -125,10 +124,6 @@ def edb(self): EDB. """ - if is_ironpython: - self.logger.warning("EDB is supported only in CPython.") - return self._edb - if settings.remote_api or settings.remote_rpc_session: return self._edb if not self._edb: diff --git a/src/ansys/aedt/core/modules/material_lib.py b/src/ansys/aedt/core/modules/material_lib.py index d3b56e1a42a..d1e6aeb0323 100644 --- a/src/ansys/aedt/core/modules/material_lib.py +++ b/src/ansys/aedt/core/modules/material_lib.py @@ -37,7 +37,6 @@ from ansys.aedt.core.generic.data_handlers import _arg2dict from ansys.aedt.core.generic.general_methods import generate_unique_name -from ansys.aedt.core.generic.general_methods import is_ironpython from ansys.aedt.core.generic.general_methods import open_file from ansys.aedt.core.generic.general_methods import pyaedt_function_handler from ansys.aedt.core.generic.general_methods import read_json @@ -899,9 +898,6 @@ def import_materials_from_excel(self, input_file): return False materials_added = [] props = {} - if is_ironpython: - self.logger.error("This method only works with CPython.") - return False if os.path.splitext(input_file)[1] == ".csv": df = pd.read_csv(input_file, index_col=0) elif os.path.splitext(input_file)[1] == ".xlsx": diff --git a/src/ansys/aedt/core/modules/solve_setup.py b/src/ansys/aedt/core/modules/solve_setup.py index d8d83b4bd50..82d0bcdebf0 100644 --- a/src/ansys/aedt/core/modules/solve_setup.py +++ b/src/ansys/aedt/core/modules/solve_setup.py @@ -42,7 +42,6 @@ from ansys.aedt.core.generic.data_handlers import _dict2arg from ansys.aedt.core.generic.general_methods import PropsManager from ansys.aedt.core.generic.general_methods import generate_unique_name -from ansys.aedt.core.generic.general_methods import is_ironpython from ansys.aedt.core.generic.general_methods import pyaedt_function_handler from ansys.aedt.core.generic.settings import settings from ansys.aedt.core.modules.setup_templates import SetupKeys @@ -1941,12 +1940,9 @@ def export_to_hfss(self, output_file, keep_net_name=False, unite=True): self.omodule.ExportToHfss(self.name, output_file) succeeded = self._check_export_log(info_messages, error_messages, output_file) if succeeded and keep_net_name: - if not is_ironpython: - from ansys.aedt.core import Hfss + from ansys.aedt.core import Hfss - self._get_net_names(Hfss, output_file, unite) - else: - self.p_app.logger.error("Exporting layout while keeping net name is not supported with IronPython") + self._get_net_names(Hfss, output_file, unite) return succeeded @pyaedt_function_handler() @@ -2094,11 +2090,8 @@ def _get_primitives_points_per_net(self): @pyaedt_function_handler() def _get_point_inside_primitive(self, primitive, n): from ansys.aedt.core.modeler.geometry_operators import GeometryOperators + import numpy as np - if not is_ironpython: - import numpy as np - else: - return False bbox = primitive.bbox primitive_x_points = [] primitive_y_points = [] @@ -2214,12 +2207,9 @@ def export_to_q3d(self, output_file, keep_net_name=False, unite=True): self.omodule.ExportToQ3d(self.name, output_file) succeeded = self._check_export_log(info_messages, error_messages, output_file) if succeeded and keep_net_name: - if not is_ironpython: - from ansys.aedt.core import Q3d + from ansys.aedt.core import Q3d - self._get_net_names(Q3d, output_file, unite) - else: - self.p_app.logger.error("Exporting layout while keeping net name is not supported with IronPython.") + self._get_net_names(Q3d, output_file, unite) return succeeded @pyaedt_function_handler(sweepname="name", sweeptype="sweep_type") diff --git a/src/ansys/aedt/core/q3d.py b/src/ansys/aedt/core/q3d.py index 79c46692839..01b42c8aed7 100644 --- a/src/ansys/aedt/core/q3d.py +++ b/src/ansys/aedt/core/q3d.py @@ -35,7 +35,6 @@ from ansys.aedt.core.generic.constants import MATRIXOPERATIONSQ2D from ansys.aedt.core.generic.constants import MATRIXOPERATIONSQ3D from ansys.aedt.core.generic.general_methods import generate_unique_name -from ansys.aedt.core.generic.general_methods import is_ironpython from ansys.aedt.core.generic.general_methods import pyaedt_function_handler from ansys.aedt.core.generic.settings import settings from ansys.aedt.core.modeler.geometry_operators import GeometryOperators as go @@ -43,11 +42,14 @@ from ansys.aedt.core.modules.boundary import Matrix from ansys.aedt.core.modules.setup_templates import SetupKeys -if not is_ironpython: - try: - import numpy as np - except ImportError: # pragma: no cover - pass +try: + import numpy as np +except ImportError: # pragma: no cover + warnings.warn( + "The NumPy module is required to use functionalities provided by the module ansys.edt.core.q3d.\n" + "Install with \n\npip install numpy" + ) + np = None class QExtractor(FieldAnalysis3D, object): @@ -1966,7 +1968,7 @@ def set_material_thresholds( if not magnetic_threshold: magnetic_threshold = 1.01 - if not is_ironpython and not self.desktop_class.is_grpc_api: + if not self.desktop_class.is_grpc_api: insulator_threshold = np.longdouble(insulator_threshold) perfect_conductor_threshold = np.longdouble(perfect_conductor_threshold) magnetic_threshold = np.longdouble(magnetic_threshold) diff --git a/src/ansys/aedt/core/rpc/rpyc_services.py b/src/ansys/aedt/core/rpc/rpyc_services.py index 80391b24be7..93a596a86de 100644 --- a/src/ansys/aedt/core/rpc/rpyc_services.py +++ b/src/ansys/aedt/core/rpc/rpyc_services.py @@ -11,19 +11,13 @@ from ansys.aedt.core import generate_unique_name from ansys.aedt.core.generic.general_methods import env_path -from ansys.aedt.core.generic.general_methods import is_ironpython from ansys.aedt.core.generic.settings import is_linux from ansys.aedt.core import is_windows from ansys.aedt.core.generic.filesystem import is_safe_path -if is_linux and is_ironpython: - import subprocessdotnet as subprocess # nosec -else: - import subprocess # nosec +import subprocess # nosec -if not is_ironpython: - import rpyc - from rpyc import ThreadedServer +import rpyc logging.basicConfig(stream=sys.stderr, level=logging.INFO) logger = logging.getLogger(__name__) @@ -885,13 +879,9 @@ def aedt_grpc(port=None, beta_options=None, use_aedt_relative_path=False, non_gr from ansys.aedt.core.generic.general_methods import grpc_active_sessions sessions = grpc_active_sessions() if not port: - # TODO: Remove once IronPython is deprecated - if is_ironpython: - port = check_port(random.randint(18500, 20000)) # nosec - else: - import secrets - secure_random = secrets.SystemRandom() - port = check_port(secure_random.randint(18500, 20000)) + import secrets + secure_random = secrets.SystemRandom() + port = check_port(secure_random.randint(18500, 20000)) if port == 0: print("Error. No ports are available.") @@ -1177,11 +1167,7 @@ def exposed_stop_service(self, port): @staticmethod def exposed_check_port(): - # TODO: Remove once IronPython is deprecated - if is_ironpython: # nosec - port = check_port(random.randint(18500, 20000)) # nosec - else: - import secrets - secure_random = secrets.SystemRandom() - port = check_port(secure_random.randint(18500, 20000)) + import secrets + secure_random = secrets.SystemRandom() + port = check_port(secure_random.randint(18500, 20000)) return port diff --git a/src/ansys/aedt/core/visualization/advanced/farfield_visualization.py b/src/ansys/aedt/core/visualization/advanced/farfield_visualization.py index a3659a88f1a..219f2cf7423 100644 --- a/src/ansys/aedt/core/visualization/advanced/farfield_visualization.py +++ b/src/ansys/aedt/core/visualization/advanced/farfield_visualization.py @@ -90,7 +90,7 @@ class FfdSolutionData(object): -------- >>> from ansys.aedt.core - >>> from ansys.aedt.core.generic.farfield_visualization import FfdSolutionData + >>> from ansys.aedt.core.visualization.advanced.farfield_visualization import FfdSolutionData >>> app = ansys.aedt.core.Hfss(version="2023.2", design="Antenna") >>> data = app.get_antenna_data() >>> metadata_file = data.metadata_file @@ -1584,7 +1584,7 @@ class UpdateBeamForm: Parameters ---------- - farfield_data : :class:`ansys.aedt.core.generic.farfield_visualization.FfdSolutionData` + farfield_data : :class:`ansys.aedt.core.visualization.advanced.farfield_visualization.FfdSolutionData` Far field solution data instance. farfield_quantity : str, optional Quantity to plot. The default is ``"RealizedGain"``. diff --git a/src/ansys/aedt/core/visualization/post/farfield_exporter.py b/src/ansys/aedt/core/visualization/post/farfield_exporter.py index b98016091e7..8edd492fe29 100644 --- a/src/ansys/aedt/core/visualization/post/farfield_exporter.py +++ b/src/ansys/aedt/core/visualization/post/farfield_exporter.py @@ -44,7 +44,8 @@ class FfdSolutionDataExporter: the embedded element pattern files for an antenna that have been solved in HFSS. The ``metadata_file`` properties can then be passed as arguments to - instantiate an instance of the :class:`ansys.aedt.core.generic.farfield_visualization.FfdSolutionData` class for + instantiate an instance of the + :class:`ansys.aedt.core.ansys.aedt.core.visualization.advanced.farfield_visualization.FfdSolutionData` class for subsequent analysis and postprocessing of the array data. Note that this class is derived from the :class:`FfdSolutionData` class and can be used directly for