Salome HOME
Windows compatibility.
[modules/yacs.git] / bin / runSalome.py
index 29b915751dfa32e5d115a7d85257bd4fce55de32..e6e79763937eb85ad290b51fa9c2ff262ba0d379 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 #  -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
 #
 # Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -41,7 +41,7 @@ from killSalome import killAllPorts
 
 def killLocalPort():
     """
-    kill servers from a previous SALOME exection, if needed,
+    kill servers from a previous SALOME execution, if needed,
     on the CORBA port given in args of runSalome
     """
 
@@ -56,7 +56,7 @@ def killLocalPort():
 
 def givenPortKill(port):
     """
-    kill servers from a previous SALOME exection, if needed,
+    kill servers from a previous SALOME execution, if needed,
     on the same CORBA port
     """
 
@@ -89,21 +89,21 @@ def kill_salome(args):
 class InterpServer(Server):
     def __init__(self,args):
         self.args=args
-        if sys.platform != "win32":
-          env_ld_library_path=['env', 'LD_LIBRARY_PATH=' + os.getenv("LD_LIBRARY_PATH")]
-          self.CMD=['xterm', '-e']+ env_ld_library_path + ['python']
-        else:
+        if sys.platform == "win32":
           self.CMD=['cmd', '/c', 'start cmd.exe', '/K', 'python']
+        elif sys.platform == "darwin":
+          env_ld_library_path=['env', 'DYLD_LIBRARY_PATH=' + os.getenv("LD_LIBRARY_PATH")]
+          self.CMD=['xterm', '-e'] + env_ld_library_path + ['python']
+        else:
+          env_ld_library_path=['env', 'LD_LIBRARY_PATH=' + os.getenv("LD_LIBRARY_PATH")]
+          self.CMD=['xterm', '-e'] + env_ld_library_path + ['python']
 
     def run(self):
         global process_id
         command = self.CMD
         print "INTERPSERVER::command = ", command
-        if sys.platform == "win32":
-          import win32pm
-          pid = win32pm.spawnpid( string.join(command, " "),'-nc' )
-        else:
-          pid = os.spawnvp(os.P_NOWAIT, command[0], command)
+        import subprocess
+        pid = subprocess.Popen(command).pid
         process_id[pid]=self.CMD
         self.PID = pid
 
@@ -189,10 +189,18 @@ class RegistryServer(Server):
 # ---
 
 class ContainerCPPServer(Server):
-    def __init__(self,args):
+    def __init__(self,args,with_gui=False):
         self.args=args
         self.initArgs()
         self.CMD=['SALOME_Container','FactoryServer']
+        if not with_gui and self.args["valgrind_session"]:
+            l = ["valgrind"]
+            val = os.getenv("VALGRIND_OPTIONS")
+            if val:
+                l += val.split()
+                pass
+            self.CMD = l + self.CMD
+            pass
 
 # ---
 
@@ -283,6 +291,8 @@ class SessionServer(Server):
             list_modules.reverse()
             self.SCMD2+=['--modules (%s)' % ":".join(list_modules)]
             pass
+        if self.args.has_key('language'):
+            self.SCMD2+=['--language=%s' % self.args['language']]
         pass
 
     def setpath(self,modules_list,modules_root_dir):
@@ -541,7 +551,7 @@ def startSalome(args, modules_list, modules_root_dir):
     #
 
     if ('cppContainer' in args['standalone']) | (args["gui"] == 0) :
-        myServer=ContainerCPPServer(args)
+        myServer=ContainerCPPServer(args, with_gui=args["gui"]!=0)
         myServer.run()
         if sys.platform == "win32":
           clt.waitNS("/Containers/" + theComputer + "/FactoryServer")
@@ -577,7 +587,7 @@ def startSalome(args, modules_list, modules_root_dir):
     #    session.GetInterface()
 
     #
-    # additionnal external python interpreters
+    # additional external python interpreters
     #
     nbaddi=0
 
@@ -742,7 +752,7 @@ def no_main():
 
 # -----------------------------------------------------------------------------
 
-def main():
+def main(exeName=None):
     """Salome launch as a main application"""
 
     # define folder to store omniorb config (initially in virtual application folder)
@@ -754,7 +764,7 @@ def main():
         sys.exit(1)
 
     from salome_utils import getHostName
-    args, modules_list, modules_root_dir = setenv.get_config()
+    args, modules_list, modules_root_dir = setenv.get_config(exeName=exeName)
     print "runSalome running on %s" % getHostName()
 
     kill_salome(args)
@@ -846,7 +856,7 @@ def runSalome():
     test = args['gui'] and args['session_gui']
     test = test or args['wake_up_session']
     # --
-    # The next test covers the --pinter option or var PYTHONINSPECT setted
+    # The next test covers the --pinter option or if var PYTHONINSPECT is set
     # --
     test = test and not os.environ.get('PYTHONINSPECT')
     # --