From: Cédric Aguerre Date: Tue, 25 Nov 2014 11:04:52 +0000 (+0100) Subject: calling YACS driver X-Git-Tag: V7_6_0a1~47 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=788743335d0833ddab8d89775da5f2dac0d5c786;p=modules%2Fkernel.git calling YACS driver --- diff --git a/bin/appliskel/salome_starter.py b/bin/appliskel/salome_starter.py index 215a49e8d..7eb0a7e5c 100644 --- a/bin/appliskel/salome_starter.py +++ b/bin/appliskel/salome_starter.py @@ -33,7 +33,7 @@ def __detectAppliPath(fromPath, launcherFile): if os.path.isdir(users_folder): return fromPath - pattern = "/bin/salome/appliskel" + pattern = os.path.sep + os.path.join("bin", "salome", "appliskel") if fromPath.endswith(pattern): currentPath = __detectAppliPath(fromPath[:-len(pattern)], launcherFile) if not currentPath is None: @@ -61,7 +61,7 @@ def initialize(launcherPath, launcherFile): os.environ['APPLI'] = appliPath # needed to convert .sh environment files os.environ['ABSOLUTE_APPLI_PATH'] = absoluteAppliPath - sys.path[:0] = [absoluteAppliPath+'/bin/salome'] + sys.path[:0] = [os.path.join(absoluteAppliPath, "bin", "salome")] # define folder to store omniorb config (initially in virtual application folder) try: diff --git a/bin/salomeContext.py b/bin/salomeContext.py index bcf54f562..cb5800693 100644 --- a/bin/salomeContext.py +++ b/bin/salomeContext.py @@ -106,8 +106,10 @@ class SalomeContext: # kill = True # args.remove(e) + import os absoluteAppliPath = os.getenv('ABSOLUTE_APPLI_PATH','') - proc = subprocess.Popen(['python', os.path.join(absoluteAppliPath,"bin","salome","salomeContext.py"), pickle.dumps(self), pickle.dumps(args)], shell=False, close_fds=True) + env_copy = os.environ.copy() + proc = subprocess.Popen(['python', os.path.join(absoluteAppliPath,"bin","salome","salomeContext.py"), pickle.dumps(self), pickle.dumps(args)], shell=False, close_fds=True, env=env_copy) msg = proc.communicate() # if kill: # self._killAll(args) @@ -203,6 +205,16 @@ class SalomeContext: See usage for details on commands. """ def _startSalome(self, args): + try: + import os + absoluteAppliPath = os.getenv('ABSOLUTE_APPLI_PATH') + import sys + path = os.path.join(absoluteAppliPath, "bin", "salome") + if not path in sys.path: + sys.path[:0] = [path] + except: + pass + command, options = self.__parseArguments(args) sys.argv = options diff --git a/bin/salomeContextUtils.py.in b/bin/salomeContextUtils.py.in index 3ff44603e..dedf40565 100644 --- a/bin/salomeContextUtils.py.in +++ b/bin/salomeContextUtils.py.in @@ -92,6 +92,10 @@ def getConfigFileNames(args, checkExistence=False): # def __getScriptPath(scriptName, searchPathList): + scriptName = os.path.expanduser(scriptName) + if os.path.isabs(scriptName): + return scriptName + if searchPathList is None or len(searchPathList) == 0: return None @@ -111,6 +115,13 @@ class ScriptAndArgs: self.script = script self.args = args self.out = out + # + def __repr__(self): + msg = "\n# Script: %s\n"%self.script + msg += " * Input: %s\n"%self.args + msg += " * Output: %s\n"%self.out + return msg + # # class ScriptAndArgsObjectEncoder(json.JSONEncoder): def default(self, obj): @@ -139,13 +150,14 @@ def getScriptsAndArgs(args=None, searchPathList=None): currentScript = None for i in range(len(args)): - elt = args[i] + elt = os.path.expanduser(args[i]) + isDriver = (elt == "driver") # special case for YACS scheme execution if elt.startswith(argsPrefix): if not currentKey or callPython: raise SalomeContextException("args list must follow corresponding script file in command line.") elt = elt.replace(argsPrefix, '') - scriptArgs[len(scriptArgs)-1].args = elt.split(",") + scriptArgs[len(scriptArgs)-1].args = [os.path.expanduser(x) for x in elt.split(",")] currentKey = None callPython = False afterArgs = True @@ -153,7 +165,7 @@ def getScriptsAndArgs(args=None, searchPathList=None): if (not currentKey and not afterArgs) or callPython: raise SalomeContextException("out list must follow both corresponding script file and its args in command line.") elt = elt.replace(outPrefix, '') - scriptArgs[len(scriptArgs)-1].out = elt.split(",") + scriptArgs[len(scriptArgs)-1].out = [os.path.expanduser(x) for x in elt.split(",")] currentKey = None callPython = False afterArgs = False @@ -170,19 +182,24 @@ def getScriptsAndArgs(args=None, searchPathList=None): elt = eltInSearchPath if elt[-4:] != ".hdf": - if elt[-3:] == ".py": + if elt[-3:] == ".py" or isDriver: currentScript = os.path.abspath(elt) elif os.path.isfile(elt+".py"): currentScript = os.path.abspath(elt+".py") else: currentScript = os.path.abspath(elt) # python script not necessary has .py extension pass + if currentScript and callPython: currentKey = "@PYTHONBIN@ "+currentScript scriptArgs.append(ScriptAndArgs(script=currentKey)) callPython = False elif currentScript: - if not os.access(currentScript, os.X_OK): + if isDriver: + currentKey = currentScript + scriptArgs.append(ScriptAndArgs(script=currentKey)) + callPython = False + elif not os.access(currentScript, os.X_OK): currentKey = "@PYTHONBIN@ "+currentScript scriptArgs.append(ScriptAndArgs(script=currentKey)) else: