Salome HOME
Handling Python scripts without execution permissions
authoraguerre <aguerre>
Wed, 28 Aug 2013 15:52:53 +0000 (15:52 +0000)
committeraguerre <aguerre>
Wed, 28 Aug 2013 15:52:53 +0000 (15:52 +0000)
bin/launchConfigureParser.py
bin/salomeLauncherUtils.py

index 4bbc9d60d0947a2aa5cd6158ca4ce9b484fa4486..b1d8aed20bfb221aef9df16f0f13845234319ea0 100755 (executable)
@@ -1020,6 +1020,14 @@ def get_env(theAdditionalOptions=[], appname=salomeappname, cfgname=salomecfgnam
 
     # Python scripts
     args[script_nam] = getScriptsAndArgs(cmd_args)
+    new_args = []
+    if args[gui_nam]:
+        for d in args[script_nam]:
+            for s, a in d.items():
+                v = re.sub(r'^python.*\s+', r'', s)
+                new_args.append({v:a})
+        #
+        args[script_nam] = new_args
 
     # xterm
     if cmd_opts.xterm is not None: args[xterm_nam] = cmd_opts.xterm
index 6d26e9c01248f995c5ce420e35e2e251b38c2b4d..6e23076ddd7562c14946b0b6cc0b91fe626d2b68 100644 (file)
@@ -62,7 +62,7 @@ def getConfigFileNames(args):
 def getScriptsAndArgs(args=[]):
   # Syntax of args: script.py [args:a1,a2=val,an] ... script.py [args:a1,a2=val,an]
   scriptArgs = []
-  currentScript = None
+  currentKey = None
   argsPrefix = "args:"
   callPython = False
 
@@ -70,11 +70,11 @@ def getScriptsAndArgs(args=[]):
     elt = args[i]
 
     if elt.startswith(argsPrefix):
-      if not currentScript or callPython:
+      if not currentKey or callPython:
         raise SalomeRunnerException("args list must follow corresponding script file in command line.")
       elt = elt.replace(argsPrefix, '')
-      scriptArgs[len(scriptArgs)-1][currentScript] = elt.split(",")
-      currentScript = None
+      scriptArgs[len(scriptArgs)-1][currentKey] = elt.split(",")
+      currentKey = None
       callPython = False
     elif elt.startswith("python"):
       callPython = True
@@ -84,12 +84,16 @@ def getScriptsAndArgs(args=[]):
       else:
         currentScript = os.path.abspath(elt+".py")
       if callPython:
-        scriptArgs.append({"python "+currentScript:[]})
+        currentKey = "python "+currentScript
+        scriptArgs.append({currentKey:[]})
         callPython = False
       else:
         if not os.access(currentScript, os.X_OK):
-          raise SalomeRunnerException("Argument %s cannot be executed (please check file permissions)"%currentScript)
-        scriptArgs.append({currentScript:[]})
+          currentKey = "python "+currentScript
+          scriptArgs.append({currentKey:[]})
+        else:
+          currentKey = currentScript
+          scriptArgs.append({currentKey:[]})
     else:
       raise SalomeRunnerException("Incorrect syntax in command line: %s:\n\t%s"%(elt," ".join(args)))
   # end for loop