Skip to content

Commit

Permalink
remove __import__ (#4445)
Browse files Browse the repository at this point in the history
Co-authored-by: maxcapodi78 <Shark78>
  • Loading branch information
maxcapodi78 authored Apr 2, 2024
1 parent d9b32e5 commit 37d8b7f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
15 changes: 4 additions & 11 deletions pyaedt/desktop.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@

modules = [tup[1] for tup in pkgutil.iter_modules()]

python_grpc_wrapper = None


@pyaedt_function_handler()
def launch_aedt(full_path, non_graphical, port, student_version, first_run=True):
Expand Down Expand Up @@ -239,7 +237,6 @@ def _close_aedt_application(desktop_class, close_desktop, pid, is_grpc_api):
``True`` when successful, ``False`` when failed.
"""
global python_grpc_wrapper
if settings.remote_rpc_session or (settings.aedt_version >= "2022.2" and is_grpc_api and not is_ironpython):
if close_desktop and desktop_class.parent_desktop_id:
pyaedt_logger.error("A child desktop session is linked to this session.")
Expand Down Expand Up @@ -273,9 +270,8 @@ def _close_aedt_application(desktop_class, close_desktop, pid, is_grpc_api):
return False
else:
try:
if not python_grpc_wrapper:
python_grpc_wrapper = __import__("pyaedt.generic.grpc_plugin")
# import pyaedt.generic.grpc_plugin as StandalonePyScriptWrapper
import pyaedt.generic.grpc_plugin as python_grpc_wrapper

python_grpc_wrapper.AedtAPI.ReleaseAll()
return True
except Exception: # pragma: no cover
Expand Down Expand Up @@ -911,7 +907,6 @@ def _initialize(
version=None,
is_grpc=True,
):
global python_grpc_wrapper
if not is_grpc:
from pyaedt.generic.clr_module import _clr

Expand All @@ -934,10 +929,8 @@ def _initialize(
os.environ["DesktopPluginPyAEDT"] = os.path.join(settings.aedt_install_dir, "PythonFiles", "DesktopPlugin")
launch_msg = "AEDT installation Path {}".format(base_path)
self.logger.info(launch_msg)
if not python_grpc_wrapper:
python_grpc_wrapper = __import__("pyaedt.generic.grpc_plugin")
python_grpc_wrapper = python_grpc_wrapper.generic.grpc_plugin
# import pyaedt.generic.grpc_plugin as StandalonePyScriptWrapper
import pyaedt.generic.grpc_plugin as python_grpc_wrapper

if _desktop_sessions:
last_session = list(_desktop_sessions.values())[-1]
all_desktop = [i for i in last_session.odesktop.GetRunningInstancesMgr().GetAllRunningInstances()]
Expand Down
2 changes: 1 addition & 1 deletion pyaedt/generic/configurations.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ def __init__(self, app):

config_schema_path = os.path.join(pyaedt_installed_path, "misc", "config.schema.json")

if os.path.isfile(config_schema_path):
if os.path.exists(config_schema_path):
with open(config_schema_path, "rb") as schema:
schema_bytes = schema.read()

Expand Down

0 comments on commit 37d8b7f

Please sign in to comment.