Salome HOME
rename salome runner/launcher as salome context
[modules/kernel.git] / bin / runSalome.py
index 311d945ee8969dd5efd6f9bf93d63e07ea6e1422..514bd07fc7339aa2061e6ce81ab584a29f4cb131 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 #  -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2007-2014  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
@@ -8,7 +8,7 @@
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
 # License as published by the Free Software Foundation; either
-# version 2.1 of the License.
+# version 2.1 of the License, or (at your option) any later version.
 #
 # This library is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -491,15 +491,6 @@ def startSalome(args, modules_list, modules_root_dir):
         args["session_object"] = session
         return clt
 
-    # Save Naming service port name into
-    # the file args["ns_port_log_file"]
-    if args.has_key('ns_port_log_file'):
-      omniorbUserPath = os.getenv("OMNIORB_USER_PATH")
-      file_name = os.path.join(omniorbUserPath, args["ns_port_log_file"])
-      f = open(file_name, "w")
-      f.write(os.environ['NSPORT'])
-      f.close()
-
     # Launch Logger Server (optional)
     # and wait until it is registered in naming service
     #
@@ -614,11 +605,6 @@ def startSalome(args, modules_list, modules_root_dir):
         else:
           clt.waitNSPID("/Containers/" + theComputer + "/FactoryServer",myServer.PID)
 
-    #
-    # Launch local Python Container (FactoryServerPy),
-    # and wait until it is registered in naming service
-    #
-
     if 'pyContainer' in args['standalone']:
         raise Exception('Python containers no longer supported')
 
@@ -763,7 +749,7 @@ def useSalome(args, modules_list, modules_root_dir):
                         import killSalomeWithPort
                         self.killSalomeWithPort = killSalomeWithPort
                         return
-                    def __del__(self):
+                    def delete(self):
                         self.killSalomeWithPort.killMyPort(self.port)
                         return
                     pass
@@ -778,12 +764,13 @@ def useSalome(args, modules_list, modules_root_dir):
                 if not args['gui'] or not args['session_gui']:
                     toimport = args['pyscript']
 
-        from salomeLauncherUtils import formatScriptsAndArgs
+        from salomeContextUtils import formatScriptsAndArgs
         command = formatScriptsAndArgs(toimport)
         if command:
             proc = subprocess.Popen(command, shell=True)
+            addToKillList(proc.pid, command, args['port'])
             res = proc.wait()
-            if not res: sys.exit(1) # if there's an error when executing script, we should explicitly exit
+            if res: sys.exit(1) # if there's an error when executing script, we should explicitly exit
 
     return clt
 
@@ -824,6 +811,11 @@ def no_main():
     from searchFreePort import searchFreePort
     searchFreePort(args, 0)
     clt = useSalome(args, modules_list, modules_root_dir)
+
+    if args.has_key('shutdown_servers') :
+        var = args['shutdown_servers']
+        if hasattr(var, 'delete') and callable(getattr(var, 'delete')) :
+            var.delete()
     return clt
 
 # -----------------------------------------------------------------------------
@@ -833,7 +825,7 @@ def main():
 
     # define folder to store omniorb config (initially in virtual application folder)
     try:
-        from salomeLauncherUtils import setOmniOrbUserPath
+        from salomeContextUtils import setOmniOrbUserPath
         setOmniOrbUserPath()
     except Exception, e:
         print e
@@ -952,6 +944,10 @@ def runSalome():
         foreGround(clt, args)
         pass
     # --
+    if args.has_key('shutdown_servers') :
+        var = args['shutdown_servers']
+        if hasattr(var, 'delete') and callable(getattr(var, 'delete')) :
+            var.delete()
     pass
 #