From 93978cc727088e3cce20feb8b001e99a3731861f Mon Sep 17 00:00:00 2001 From: aguerre Date: Wed, 28 Aug 2013 15:52:53 +0000 Subject: [PATCH] Handling Python scripts without execution permissions --- bin/launchConfigureParser.py | 8 ++++++++ bin/salomeLauncherUtils.py | 18 +++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/bin/launchConfigureParser.py b/bin/launchConfigureParser.py index 4bbc9d60d..b1d8aed20 100755 --- a/bin/launchConfigureParser.py +++ b/bin/launchConfigureParser.py @@ -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 diff --git a/bin/salomeLauncherUtils.py b/bin/salomeLauncherUtils.py index 6d26e9c01..6e23076dd 100644 --- a/bin/salomeLauncherUtils.py +++ b/bin/salomeLauncherUtils.py @@ -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 -- 2.39.2