Salome HOME
0023299: [CEA] Finalize multi-study removal
[modules/kernel.git] / bin / runSalome.py
index da1c5694681cc92206d4351673d76bec3c0732d1..b547c3703b69e025e538fa587125469f1964888b 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 #  -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-2014  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
@@ -99,11 +99,8 @@ class InterpServer(Server):
         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
 
@@ -140,29 +137,6 @@ def get_cata_path(list_modules,modules_root_dir):
 
     return cata_path
 
-_siman_name = None
-def simanStudyName(args):
-    global _siman_name
-    if _siman_name is None:
-        # siman session paramenters and checkout processing
-        _siman_name = ""
-        if 'siman' in args:
-            siman_data = []
-            for param in [ 'study', 'scenario', 'user']:
-                siman_param = "siman_%s"%param
-                if siman_param in args:
-                    siman_data.append(args[siman_param])
-                else:
-                    print "SIMAN %s must be defined using parameter --siman-%s=XXX" % (siman_param, siman_param)
-                    pass
-                pass
-            if len(siman_data) == 3:
-                _siman_name = "_".join(siman_data)
-                pass
-            pass
-        pass
-    return _siman_name
-
 class CatalogServer(Server):
     def __init__(self,args):
         self.args=args
@@ -281,9 +255,6 @@ class SessionServer(Server):
                 if self.args['study_hdf'] is not None:
                     self.SCMD2+=['--study-hdf=%s'%self.args['study_hdf']]
                     pass
-                if simanStudyName(self.args):
-                    self.SCMD2+=['--siman-study=%s'%simanStudyName(self.args)]
-                    pass
                 pass
                 if self.args.has_key('pyscript') and len(self.args['pyscript']) > 0:
                     msg = json.dumps(self.args['pyscript'], cls=ScriptAndArgsObjectEncoder)
@@ -484,14 +455,6 @@ def startSalome(args, modules_list, modules_root_dir):
         myServer.run()
         clt.waitLogger("Logger")
 
-    # 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
-        from salome_utils import getTmpDir
-        ppath = os.path.join(getTmpDir, "SimanSalome", args['siman_study'],
-                             args['siman_scenario'], args['siman_user'])
-        os.environ["PYTHONPATH"] = ppath + os.pathsep + os.environ["PYTHONPATH"]
-
     # Launch  Session Server (to show splash ASAP)
     #
 
@@ -539,9 +502,9 @@ def startSalome(args, modules_list, modules_root_dir):
         myServer=SalomeDSServer(args)
         myServer.run()
         if sys.platform == "win32":
-          clt.waitNS("/myStudyManager")
+          clt.waitNS("/Study")
         else:
-          clt.waitNSPID("/myStudyManager",myServer.PID)
+          clt.waitNSPID("/Study",myServer.PID)
 
     #
     # Launch LauncherServer
@@ -640,27 +603,6 @@ def startSalome(args, modules_list, modules_root_dir):
         except ImportError:
             pass
 
-    # siman session paramenters and checkout processing
-    if simanStudyName(args):
-        print '**********************************************'
-        print "Siman study name= '" + simanStudyName(args) + "'"
-        import SALOMEDS
-        obj = clt.Resolve('myStudyManager')
-        myStudyManager = obj._narrow(SALOMEDS.StudyManager)
-        aNewStudy = myStudyManager.NewStudy(simanStudyName(args))
-        aSimS = myStudyManager.GetSimanStudy()
-        aSimS._set_StudyId(args['siman_study'])
-        aSimS._set_ScenarioId(args['siman_scenario'])
-        aSimS._set_UserId(args['siman_user'])
-        aSimS.CheckOut(aNewStudy)
-        # if session server is enabled, activate the created study
-        if args["gui"]:
-            print "Activate the SIMAN study in the SALOME GUI"
-            obj = clt.Resolve('/Kernel/Session')
-            mySession = obj._narrow(SALOME.Session)
-            mySession.emitMessage("simanCheckoutDone " + simanStudyName(args))
-        print '**********************************************'
-
     return clt
 
 # -----------------------------------------------------------------------------
@@ -760,7 +702,7 @@ def useSalome(args, modules_list, modules_root_dir):
 
 def execScript(script_path):
     print 'executing', script_path
-    sys.path.insert(0, os.path.dirname(script_path))
+    sys.path.insert(0, os.path.realpath(os.path.dirname(script_path)))
     execfile(script_path,globals())
     del sys.path[0]
 
@@ -773,7 +715,8 @@ def registerEnv(args, modules_list, modules_root_dir):
     """
     from salome_utils import getTmpDir
     fileEnv = getTmpDir()
-    fileEnv += os.getenv('USER') + "_" + str(args['port']) \
+    from salome_utils import getUserName
+    fileEnv += getUserName() + "_" + str(args['port']) \
             + '_' + args['appname'].upper() + '_env'
     fenv=open(fileEnv,'w')
     pickle.dump((args, modules_list, modules_root_dir),fenv)
@@ -796,7 +739,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)
@@ -808,7 +751,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)