Salome HOME
'[CEA 19927] Folders with spaces' : second part
authorrnv <rnv@opencascade.com>
Tue, 1 Sep 2020 11:04:25 +0000 (14:04 +0300)
committerrnv <rnv@opencascade.com>
Tue, 1 Sep 2020 11:04:25 +0000 (14:04 +0300)
bin/runSalome.py
bin/salomeContextUtils.py.in

index b5dad97317965c1b0850a414ed3067b8655fd1f6..b4fc7270f7634d38549f529798fe2d33d33209f3 100755 (executable)
@@ -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'])
index c45076dd5352ed195ab247544cb5ed4f39f18ff9..c288b57ec07d41910f42eaab796f9c85a19a5cb0 100644 (file)
@@ -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)