From 24f3cfecf4daa461a2fa6a007ab3a0f9b991400f Mon Sep 17 00:00:00 2001 From: rnv Date: Tue, 1 Sep 2020 14:04:25 +0300 Subject: [PATCH] '[CEA 19927] Folders with spaces' : second part --- bin/runSalome.py | 2 +- bin/salomeContextUtils.py.in | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/bin/runSalome.py b/bin/runSalome.py index b5dad9731..b4fc7270f 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -751,7 +751,7 @@ def useSalome(args, modules_list, modules_root_dir): if 'pyscript' in args: toimport = args['pyscript'] from salomeContextUtils import formatScriptsAndArgs - command = formatScriptsAndArgs(toimport) + command = formatScriptsAndArgs(toimport, escapeSpaces=True) if command: proc = subprocess.Popen(command, shell=True) addToKillList(proc.pid, command, args['port']) diff --git a/bin/salomeContextUtils.py.in b/bin/salomeContextUtils.py.in index c45076dd5..c288b57ec 100644 --- a/bin/salomeContextUtils.py.in +++ b/bin/salomeContextUtils.py.in @@ -286,12 +286,18 @@ def getScriptsAndArgs(args=None, searchPathList=None): # Formatting scripts and args as a Bash-like command-line: # script1.py [args] ; script2.py [args] ; ... # scriptArgs is a list of ScriptAndArgs objects; their output parameters are omitted -def formatScriptsAndArgs(scriptArgs=None): +def formatScriptsAndArgs(scriptArgs=None, escapeSpaces=False): if scriptArgs is None: return "" commands = [] for sa_obj in scriptArgs: cmd = sa_obj.script + if escapeSpaces and cmd: + if sys.platform == "win32": + cmd = cmd.replace(' ', ' "', 1) + cmd = cmd + '"' + else: + cmd = cmd.replace(' ', '\ ').replace('\ ', ' ', 1) if sa_obj.args: cmd = " ".join([cmd]+sa_obj.args) commands.append(cmd) -- 2.39.2