Skip to content

Commit 149bd79

Browse files
committed
Fixing launch behavior for various Windows shell environments (#2217)
fixing behavior for different windows shell environments
1 parent 84ca22a commit 149bd79

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

src/ansys/fluent/core/launcher/launcher.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,11 @@ def _build_fluent_launch_args_string(**kwargs) -> str:
252252
launch_args_string += v["fluent_format"].replace("{}", str(argval))
253253
addArgs = kwargs["additional_arguments"]
254254
if "-t" not in addArgs and "-cnf=" not in addArgs:
255-
mlist = load_machines(ncores=kwargs["processor_count"])
256-
launch_args_string += " " + build_parallel_options(mlist)
255+
parallel_options = build_parallel_options(
256+
load_machines(ncores=kwargs["processor_count"])
257+
)
258+
if parallel_options:
259+
launch_args_string += " " + parallel_options
257260
return launch_args_string
258261

259262

@@ -433,15 +436,20 @@ def _generate_launch_string(
433436
):
434437
"""Generates the launch string to launch fluent."""
435438
if _is_windows():
436-
exe_path = '"' + str(get_fluent_exe_path(**argvals)) + '"'
439+
exe_path = str(get_fluent_exe_path(**argvals))
440+
if " " in exe_path:
441+
exe_path = '"' + exe_path + '"'
437442
else:
438443
exe_path = str(get_fluent_exe_path(**argvals))
439444
launch_string = exe_path
440445
launch_string += _build_fluent_launch_args_string(**argvals)
441446
if meshing_mode:
442447
launch_string += " -meshing"
443-
launch_string += f" {additional_arguments}"
444-
launch_string += f' -sifile="{server_info_filepath}"'
448+
if additional_arguments:
449+
launch_string += f" {additional_arguments}"
450+
if " " in server_info_filepath:
451+
server_info_filepath = '"' + server_info_filepath + '"'
452+
launch_string += f" -sifile={server_info_filepath}"
445453
launch_string += " -nm"
446454
launch_string = _update_launch_string_wrt_gui_options(
447455
launch_string, show_gui, additional_arguments

src/ansys/fluent/core/launcher/watchdog.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,12 @@ def launch(
8686
python_executable = pythonw_executable
8787
else:
8888
logger.debug("Could not find Windows 'pythonw.exe' executable.")
89-
python_executable = '"' + str(python_executable) + '"'
90-
watchdog_exec = '"' + str(watchdog_exec) + '"'
89+
python_executable = str(python_executable)
90+
watchdog_exec = str(watchdog_exec)
91+
if " " in python_executable:
92+
python_executable = '"' + str(python_executable) + '"'
93+
if " " in watchdog_exec:
94+
watchdog_exec = '"' + str(watchdog_exec) + '"'
9195

9296
# Command to be executed by the new process
9397
command_list = [

0 commit comments

Comments
 (0)