]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
calling YACS driver
authorCédric Aguerre <cedric.aguerre@edf.fr>
Tue, 25 Nov 2014 11:04:52 +0000 (12:04 +0100)
committerCédric Aguerre <cedric.aguerre@edf.fr>
Wed, 26 Nov 2014 14:15:37 +0000 (15:15 +0100)
bin/appliskel/salome_starter.py
bin/salomeContext.py
bin/salomeContextUtils.py.in

index 215a49e8d4e6a27c1b01205b62004c67e4b7f20f..7eb0a7e5c8421334b1546706d5045b8878441635 100644 (file)
@@ -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:
index bcf54f5626156e74acd8e35d04eecbe67ca8b1aa..cb580069388fa384bca46f1365d67b9dade68733 100644 (file)
@@ -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
 
index 3ff44603e3c57d0ff7913cb3782222bce14e0973..dedf4056563b674893c4d9989920982c8b0b38a1 100644 (file)
@@ -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: