Skip to content

Commit 914e0f3

Browse files
b-matteoRobPasMue
authored andcommitted
Feat/launcher hidden mode (#861)
1 parent 9a5968f commit 914e0f3

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

src/ansys/geometry/core/connection/launcher.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ def launch_modeler_with_discovery(
370370
timeout: int = 150,
371371
manifest_path: str = None,
372372
logs_folder: str = None,
373+
hidden: bool = False,
373374
):
374375
"""
375376
Start Ansys Discovery locally using the ``ProductInstance`` class.
@@ -420,6 +421,7 @@ def launch_modeler_with_discovery(
420421
version.
421422
logs_folder : sets the backend's logs folder path. If nothing is defined,
422423
the backend will use its default path.
424+
hidden : starts the product hiding its UI. Default is ``False``.
423425
424426
Raises
425427
------
@@ -465,6 +467,7 @@ def launch_modeler_with_discovery(
465467
timeout=timeout,
466468
manifest_path=manifest_path,
467469
logs_folder=logs_folder,
470+
hidden=hidden,
468471
)
469472

470473

@@ -477,6 +480,7 @@ def launch_modeler_with_spaceclaim(
477480
timeout: int = 150,
478481
manifest_path: str = None,
479482
logs_folder: str = None,
483+
hidden: bool = False,
480484
):
481485
"""
482486
Start Ansys SpaceClaim locally using the ``ProductInstance`` class.
@@ -524,6 +528,7 @@ def launch_modeler_with_spaceclaim(
524528
version.
525529
logs_folder : sets the backend's logs folder path. If nothing is defined,
526530
the backend will use its default path.
531+
hidden : starts the product hiding its UI. Default is ``False``.
527532
528533
Raises
529534
------
@@ -569,6 +574,7 @@ def launch_modeler_with_spaceclaim(
569574
timeout=timeout,
570575
manifest_path=manifest_path,
571576
logs_folder=logs_folder,
577+
hidden=hidden,
572578
)
573579

574580

src/ansys/geometry/core/connection/product_instance.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,27 @@
102102
To be used only with Ansys Discovery and Ansys SpaceClaim.
103103
"""
104104

105+
BACKEND_SPACECLAIM_HIDDEN = "/Headless=True"
106+
"""
107+
The argument to hide SpaceClaim's UI on the backend.
108+
109+
To be used only with Ansys SpaceClaim.
110+
"""
111+
112+
BACKEND_DISCOVERY_HIDDEN = "--hidden"
113+
"""
114+
The argument to hide Discovery's UI on the backend.
115+
116+
To be used only with Ansys Discovery.
117+
"""
118+
119+
BACKEND_SPLASH_OFF = "/Splash=False"
120+
"""
121+
The argument to specify the backend's addin manifest file's path.
122+
123+
To be used only with Ansys Discovery and Ansys SpaceClaim.
124+
"""
125+
105126

106127
class ProductInstance:
107128
"""
@@ -143,6 +164,7 @@ def prepare_and_start_backend(
143164
timeout: int = 150,
144165
manifest_path: str = None,
145166
logs_folder: str = None,
167+
hidden: bool = False,
146168
) -> "Modeler":
147169
"""
148170
Start the requested service locally using the ``ProductInstance`` class.
@@ -187,6 +209,7 @@ def prepare_and_start_backend(
187209
version. Only applicable for Ansys Discovery and Ansys SpaceClaim.
188210
logs_folder : sets the backend's logs folder path. If nothing is defined,
189211
the backend will use its default path.
212+
hidden : starts the product hiding its UI. Default is ``False``.
190213
191214
Raises
192215
------
@@ -223,6 +246,10 @@ def prepare_and_start_backend(
223246

224247
if backend_type == BackendType.DISCOVERY:
225248
args.append(os.path.join(installations[product_version], DISCOVERY_FOLDER, DISCOVERY_EXE))
249+
if hidden is True:
250+
args.append(BACKEND_DISCOVERY_HIDDEN)
251+
252+
# Here begins the spaceclaim arguments.
226253
args.append(BACKEND_SPACECLAIM_OPTIONS)
227254
args.append(
228255
BACKEND_ADDIN_MANIFEST_ARGUMENT
@@ -231,6 +258,9 @@ def prepare_and_start_backend(
231258
env_copy[BACKEND_API_VERSION_VARIABLE] = str(api_version)
232259
elif backend_type == BackendType.SPACECLAIM:
233260
args.append(os.path.join(installations[product_version], SPACECLAIM_FOLDER, SPACECLAIM_EXE))
261+
if hidden is True:
262+
args.append(BACKEND_SPACECLAIM_HIDDEN)
263+
args.append(BACKEND_SPLASH_OFF)
234264
args.append(
235265
BACKEND_ADDIN_MANIFEST_ARGUMENT
236266
+ _manifest_path_provider(product_version, installations, manifest_path)

tests/integration/test_launcher_product.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ def test_product_launch_with_parameters():
9191
log_level=random.randint(0, 3),
9292
api_version=apiVersions[random.randint(0, len(apiVersions) - 1)].value,
9393
timeout=180,
94+
hidden=True,
9495
)
9596

9697
modeler_spaceclaim = launch_modeler_with_spaceclaim(
@@ -99,6 +100,7 @@ def test_product_launch_with_parameters():
99100
log_level=random.randint(0, 3),
100101
api_version=apiVersions[random.randint(0, len(apiVersions) - 1)].value,
101102
timeout=180,
103+
hidden=True,
102104
)
103105

104106
assert modeler_geo_service != None

0 commit comments

Comments
 (0)