Salome HOME
Correction of bug for HPContainers shared by different scripts.
[modules/kernel.git] / bin / runSalome.py
index fef35cf21c81d3db71d4ae6159b63aecb606404b..c819b857c8513c044d2a650d8e4e63e69cbf26d6 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
@@ -393,21 +393,6 @@ class LauncherServer(Server):
             self.CMD=self.SCMD1 + ['"' + string.join(cata_path,'"::"') + '"'] + self.SCMD2
         else:
             self.CMD=self.SCMD1 + self.SCMD2
-
-class NotifyServer(Server):
-    def __init__(self,args,modules_root_dir):
-        self.args=args
-        self.initArgs()
-        self.modules_root_dir=modules_root_dir
-        myLogName = os.environ["LOGNAME"]
-        self.CMD=['notifd','-c',
-                  self.modules_root_dir["KERNEL"] +'/share/salome/resources/kernel/channel.cfg',
-                  '-DFactoryIORFileName=/tmp/'+myLogName+'_rdifact.ior',
-                  '-DChannelIORFileName=/tmp/'+myLogName+'_rdichan.ior',
-                  '-DReportLogFile=/tmp/'+myLogName+'_notifd.report',
-                  '-DDebugLogFile=/tmp/'+myLogName+'_notifd.debug',
-                  ]
-
 #
 # -----------------------------------------------------------------------------
 
@@ -491,15 +476,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
     #
@@ -509,15 +485,6 @@ def startSalome(args, modules_list, modules_root_dir):
         myServer.run()
         clt.waitLogger("Logger")
 
-    # Notify Server launch
-    #
-
-    if sys.platform != "win32":
-      if verbose(): print "Notify Server to launch"
-
-      myServer=NotifyServer(args,modules_root_dir)
-      myServer.run()
-
     # set siman python path before the session server launching to import scripts inside python console
     if simanStudyName(args):
         # MPV: use os.environ here because session server is launched in separated process and sys.path is missed in this case
@@ -614,11 +581,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')
 
@@ -767,7 +729,10 @@ def useSalome(args, modules_list, modules_root_dir):
                         self.killSalomeWithPort.killMyPort(self.port)
                         return
                     pass
-                args['shutdown_servers'] = __utils__(args['port'])
+                def func(s):
+                    del s
+                import atexit
+                atexit.register(func, __utils__(args['port']))
                 pass
             pass
 
@@ -778,10 +743,11 @@ 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 res: sys.exit(1) # if there's an error when executing script, we should explicitly exit
 
@@ -833,15 +799,15 @@ 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
         sys.exit(1)
 
     from salome_utils import getHostName
-    print "runSalome running on %s" % getHostName()
     args, modules_list, modules_root_dir = setenv.get_config()
+    print "runSalome running on %s" % getHostName()
 
     kill_salome(args)
     save_config = True
@@ -951,7 +917,6 @@ def runSalome():
     if test:
         foreGround(clt, args)
         pass
-    # --
     pass
 #