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:
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:
# 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)
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
#
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
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):
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
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
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: