Skip to content

Commit 37d8b7f

Browse files
authored
remove __import__ (#4445)
Co-authored-by: maxcapodi78 <Shark78>
1 parent d9b32e5 commit 37d8b7f

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

pyaedt/desktop.py

+4-11
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@
5858

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

61-
python_grpc_wrapper = None
62-
6361

6462
@pyaedt_function_handler()
6563
def launch_aedt(full_path, non_graphical, port, student_version, first_run=True):
@@ -239,7 +237,6 @@ def _close_aedt_application(desktop_class, close_desktop, pid, is_grpc_api):
239237
``True`` when successful, ``False`` when failed.
240238
241239
"""
242-
global python_grpc_wrapper
243240
if settings.remote_rpc_session or (settings.aedt_version >= "2022.2" and is_grpc_api and not is_ironpython):
244241
if close_desktop and desktop_class.parent_desktop_id:
245242
pyaedt_logger.error("A child desktop session is linked to this session.")
@@ -273,9 +270,8 @@ def _close_aedt_application(desktop_class, close_desktop, pid, is_grpc_api):
273270
return False
274271
else:
275272
try:
276-
if not python_grpc_wrapper:
277-
python_grpc_wrapper = __import__("pyaedt.generic.grpc_plugin")
278-
# import pyaedt.generic.grpc_plugin as StandalonePyScriptWrapper
273+
import pyaedt.generic.grpc_plugin as python_grpc_wrapper
274+
279275
python_grpc_wrapper.AedtAPI.ReleaseAll()
280276
return True
281277
except Exception: # pragma: no cover
@@ -911,7 +907,6 @@ def _initialize(
911907
version=None,
912908
is_grpc=True,
913909
):
914-
global python_grpc_wrapper
915910
if not is_grpc:
916911
from pyaedt.generic.clr_module import _clr
917912

@@ -934,10 +929,8 @@ def _initialize(
934929
os.environ["DesktopPluginPyAEDT"] = os.path.join(settings.aedt_install_dir, "PythonFiles", "DesktopPlugin")
935930
launch_msg = "AEDT installation Path {}".format(base_path)
936931
self.logger.info(launch_msg)
937-
if not python_grpc_wrapper:
938-
python_grpc_wrapper = __import__("pyaedt.generic.grpc_plugin")
939-
python_grpc_wrapper = python_grpc_wrapper.generic.grpc_plugin
940-
# import pyaedt.generic.grpc_plugin as StandalonePyScriptWrapper
932+
import pyaedt.generic.grpc_plugin as python_grpc_wrapper
933+
941934
if _desktop_sessions:
942935
last_session = list(_desktop_sessions.values())[-1]
943936
all_desktop = [i for i in last_session.odesktop.GetRunningInstancesMgr().GetAllRunningInstances()]

pyaedt/generic/configurations.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ def __init__(self, app):
697697

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

700-
if os.path.isfile(config_schema_path):
700+
if os.path.exists(config_schema_path):
701701
with open(config_schema_path, "rb") as schema:
702702
schema_bytes = schema.read()
703703

0 commit comments

Comments
 (0)