2 # -*- coding: iso-8859-1 -*-
3 # Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
5 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
6 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
8 # This library is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU Lesser General Public
10 # License as published by the Free Software Foundation; either
11 # version 2.1 of the License.
13 # This library is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # Lesser General Public License for more details.
18 # You should have received a copy of the GNU Lesser General Public
19 # License along with this library; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
26 # \brief Module that provides services to launch SALOME
29 import sys, os, string, glob, time, pickle, re
32 from launchConfigureParser import verbose
33 from server import process_id, Server
35 from salomeLauncherUtils import formatScriptsAndArgs
38 # -----------------------------------------------------------------------------
40 from killSalome import killAllPorts
44 kill servers from a previous SALOME exection, if needed,
45 on the CORBA port given in args of runSalome
48 from killSalomeWithPort import killMyPort
49 my_port=str(args['port'])
53 print "problem in killLocalPort()"
57 def givenPortKill(port):
59 kill servers from a previous SALOME exection, if needed,
60 on the same CORBA port
63 from killSalomeWithPort import killMyPort
68 print "problem in LocalPortKill(), killMyPort(%s)"%port
72 def kill_salome(args):
74 Kill servers from previous SALOME executions, if needed;
75 depending on args 'killall' or 'portkill', kill all executions,
76 or only execution on the same CORBA port
81 elif args['portkill']:
82 givenPortKill(str(args['port']))
84 # -----------------------------------------------------------------------------
86 # Class definitions to launch CORBA Servers
89 class InterpServer(Server):
90 def __init__(self,args):
92 if sys.platform != "win32":
93 env_ld_library_path=['env', 'LD_LIBRARY_PATH=' + os.getenv("LD_LIBRARY_PATH")]
94 self.CMD=['xterm', '-e']+ env_ld_library_path + ['python']
96 self.CMD=['cmd', '/c', 'start cmd.exe', '/K', 'python']
101 print "INTERPSERVER::command = ", command
102 if sys.platform == "win32":
104 pid = win32pm.spawnpid( string.join(command, " "),'-nc' )
106 pid = os.spawnvp(os.P_NOWAIT, command[0], command)
107 process_id[pid]=self.CMD
112 def get_cata_path(list_modules,modules_root_dir):
113 """Build a list of catalog paths (cata_path) to initialize the ModuleCatalog server
118 for module in list_modules:
119 if modules_root_dir.has_key(module):
120 module_root_dir=modules_root_dir[module]
121 module_cata=module+"Catalog.xml"
122 cata_file=os.path.join(module_root_dir, "share",setenv.salome_subdir, "resources",module.lower(), module_cata)
124 if os.path.exists(cata_file):
125 cata_path.append(cata_file)
126 modules_cata[module]=cata_file
128 cata_file=os.path.join(module_root_dir, "share",setenv.salome_subdir, "resources", module_cata)
129 if os.path.exists(cata_file):
130 cata_path.append(cata_file)
131 modules_cata[module]=cata_file
133 for path in os.getenv("SALOME_CATALOGS_PATH","").split(os.pathsep):
134 if os.path.exists(path):
135 for cata_file in glob.glob(os.path.join(path,"*Catalog.xml")):
136 module_name= os.path.basename(cata_file)[:-11]
137 if not modules_cata.has_key(module_name):
138 cata_path.append(cata_file)
139 modules_cata[module_name]=cata_file
144 def simanStudyName(args):
146 if _siman_name is None:
147 # siman session paramenters and checkout processing
151 for param in [ 'study', 'scenario', 'user']:
152 siman_param = "siman_%s"%param
153 if siman_param in args:
154 siman_data.append(args[siman_param])
156 print "SIMAN %s must be defined using parameter --siman-%s=XXX" % (siman_param, siman_param)
159 if len(siman_data) == 3:
160 _siman_name = "_".join(siman_data)
166 class CatalogServer(Server):
167 def __init__(self,args):
170 self.SCMD1=['SALOME_ModuleCatalog_Server','-common']
172 home_dir=os.getenv('HOME')
173 if home_dir is not None:
174 self.SCMD2=['-personal',os.path.join(home_dir,'Salome/resources/CatalogModulePersonnel.xml')]
176 def setpath(self,modules_list,modules_root_dir):
177 list_modules = modules_list[:]
178 list_modules.reverse()
179 if self.args["gui"] :
180 list_modules = ["KERNEL", "GUI"] + list_modules
182 list_modules = ["KERNEL"] + list_modules
184 cata_path=get_cata_path(list_modules,modules_root_dir)
186 self.CMD=self.SCMD1 + ['"' + string.join(cata_path,'"::"') + '"'] + self.SCMD2
190 class SalomeDSServer(Server):
191 def __init__(self,args):
194 self.CMD=['SALOMEDS_Server']
198 class ConnectionManagerServer(Server):
199 def __init__(self,args):
202 self.CMD=['SALOME_ConnectionManagerServer']
206 class RegistryServer(Server):
207 def __init__(self,args):
210 self.CMD=['SALOME_Registry_Server', '--salome_session','theSession']
214 class ContainerCPPServer(Server):
215 def __init__(self,args):
218 self.CMD=['SALOME_Container','FactoryServer']
222 class LoggerServer(Server):
223 def __init__(self,args):
226 from salome_utils import generateFileName
227 if sys.platform == "win32": dirpath = os.environ["HOME"]
228 else: dirpath = "/tmp"
229 logfile = generateFileName( dirpath,
235 print "==========================================================="
236 print "Logger server: put log to the file:"
238 print "==========================================================="
239 self.CMD=['SALOME_Logger_Server', logfile]
241 pass # end of LoggerServer class
245 class SessionServer(Server):
246 def __init__(self,args,modules_list,modules_root_dir):
247 self.args = args.copy()
248 # Bug 11512 (Problems with runSalome --xterm on Mandrake and Debian Sarge)
249 #self.args['xterm']=0
252 self.SCMD1=['SALOME_Session_Server']
254 if 'registry' in self.args['embedded']:
255 self.SCMD1+=['--with','Registry',
256 '(','--salome_session','theSession',')']
257 if 'moduleCatalog' in self.args['embedded']:
258 self.SCMD1+=['--with','ModuleCatalog','(','-common']
259 home_dir=os.getenv('HOME')
260 if home_dir is not None:
261 self.SCMD2+=['-personal',os.path.join(home_dir,'Salome/resources/CatalogModulePersonnel.xml')]
263 if 'study' in self.args['embedded']:
264 self.SCMD2+=['--with','SALOMEDS','(',')']
265 if 'cppContainer' in self.args['embedded']:
266 self.SCMD2+=['--with','Container','(','FactoryServer',')']
267 if 'SalomeAppEngine' in self.args['embedded']:
268 self.SCMD2+=['--with','SalomeAppEngine','(',')']
270 if 'cppContainer' in self.args['standalone'] or 'cppContainer' in self.args['embedded']:
272 if 'pyContainer' in self.args['standalone'] or 'pyContainer' in self.args['embedded']:
273 raise Exception('Python containers no longer supported')
276 if self.args.has_key('session_gui'):
277 session_gui = self.args['session_gui']
280 if self.args['splash']:
281 self.SCMD2+=['SPLASH']
283 if self.args['study_hdf'] is not None:
284 self.SCMD2+=['--study-hdf=%s'%self.args['study_hdf']]
286 if simanStudyName(self.args):
287 self.SCMD2+=['--siman-study=%s'%simanStudyName(self.args)]
290 if self.args.has_key('pyscript') and len(self.args['pyscript']) > 0:
291 msg = json.dumps(self.args['pyscript'])
292 self.SCMD2+=['--pyscript=%s'%(msg)]
296 if self.args['noexcepthandler']:
297 self.SCMD2+=['noexcepthandler']
298 if self.args.has_key('user_config'):
299 self.SCMD2+=['--resources=%s'%self.args['user_config']]
300 if self.args.has_key('modules'):
302 #keep only modules with GUI
303 for m in modules_list:
304 if m not in modules_root_dir:
305 list_modules.insert(0,m)
307 fr1 = os.path.join(modules_root_dir[m],"share","salome","resources",m.lower(),"SalomeApp.xml")
308 fr2 = os.path.join(modules_root_dir[m],"share","salome","resources","SalomeApp.xml")
309 if os.path.exists(fr1) or os.path.exists(fr2):
310 list_modules.insert(0,m)
311 list_modules.reverse()
312 self.SCMD2+=['--modules (%s)' % ":".join(list_modules)]
316 def setpath(self,modules_list,modules_root_dir):
317 list_modules = modules_list[:]
318 list_modules.reverse()
319 if self.args["gui"] :
320 list_modules = ["KERNEL", "GUI"] + list_modules
322 list_modules = ["KERNEL"] + list_modules
324 cata_path=get_cata_path(list_modules,modules_root_dir)
326 if (self.args["gui"]) & ('moduleCatalog' in self.args['embedded']):
327 #Use '::' instead ":" because drive path with "D:\" is invalid on windows platform
328 self.CMD=self.SCMD1 + ['"' + string.join(cata_path,'"::"') + '"'] + self.SCMD2
330 self.CMD=self.SCMD1 + self.SCMD2
331 if self.args.has_key('test'):
332 self.CMD+=['-test'] + self.args['test']
333 elif self.args.has_key('play'):
334 self.CMD+=['-play'] + self.args['play']
336 if self.args["gdb_session"] or self.args["ddd_session"]:
337 f = open(".gdbinit4salome", "w")
339 args = " ".join(self.CMD[1:])
340 args = args.replace("(", "\(")
341 args = args.replace(")", "\)")
345 if self.args["ddd_session"]:
346 self.CMD = ["ddd", "--command=.gdbinit4salome", self.CMD[0]]
347 elif self.args["gdb_session"]:
348 self.CMD = ["xterm", "-e", "gdb", "--command=.gdbinit4salome", self.CMD[0]]
352 if self.args["valgrind_session"]:
354 val = os.getenv("VALGRIND_OPTIONS")
358 self.CMD = l + self.CMD
363 class LauncherServer(Server):
364 def __init__(self,args):
367 self.SCMD1=['SALOME_LauncherServer']
370 if 'registry' in self.args['embedded']:
371 self.SCMD1+=['--with','Registry',
372 '(','--salome_session','theSession',')']
373 if 'moduleCatalog' in self.args['embedded']:
374 self.SCMD1+=['--with','ModuleCatalog','(','-common']
375 self.SCMD2+=['-personal',
376 '${HOME}/Salome/resources/CatalogModulePersonnel.xml',')']
377 if 'study' in self.args['embedded']:
378 self.SCMD2+=['--with','SALOMEDS','(',')']
379 if 'cppContainer' in self.args['embedded']:
380 self.SCMD2+=['--with','Container','(','FactoryServer',')']
382 def setpath(self,modules_list,modules_root_dir):
383 list_modules = modules_list[:]
384 list_modules.reverse()
385 if self.args["gui"] :
386 list_modules = ["KERNEL", "GUI"] + list_modules
388 list_modules = ["KERNEL"] + list_modules
390 cata_path=get_cata_path(list_modules,modules_root_dir)
392 if (self.args["gui"]) & ('moduleCatalog' in self.args['embedded']):
393 #Use '::' instead ":" because drive path with "D:\" is invalid on windows platform
394 self.CMD=self.SCMD1 + ['"' + string.join(cata_path,'"::"') + '"'] + self.SCMD2
396 self.CMD=self.SCMD1 + self.SCMD2
398 class NotifyServer(Server):
399 def __init__(self,args,modules_root_dir):
402 self.modules_root_dir=modules_root_dir
403 myLogName = os.environ["LOGNAME"]
404 self.CMD=['notifd','-c',
405 self.modules_root_dir["KERNEL"] +'/share/salome/resources/kernel/channel.cfg',
406 '-DFactoryIORFileName=/tmp/'+myLogName+'_rdifact.ior',
407 '-DChannelIORFileName=/tmp/'+myLogName+'_rdichan.ior',
408 '-DReportLogFile=/tmp/'+myLogName+'_notifd.report',
409 '-DDebugLogFile=/tmp/'+myLogName+'_notifd.debug',
413 # -----------------------------------------------------------------------------
416 """Salome Session Graphic User Interface activation"""
420 import SALOME_ModuleCatalog
421 import SALOME_Session_idl
422 session=clt.waitNS("/Kernel/Session",SALOME.Session)
423 session.GetInterface()
425 # -----------------------------------------------------------------------------
427 def startSalome(args, modules_list, modules_root_dir):
428 """Launch all SALOME servers requested by args"""
429 init_time = os.times()
431 if verbose(): print "startSalome ", args
434 # Set server launch command
436 if args.has_key('server_launch_mode'):
437 Server.set_server_launch_mode(args['server_launch_mode'])
440 # Wake up session option
442 if args['wake_up_session']:
443 if "OMNIORB_CONFIG" not in os.environ:
444 from salome_utils import generateFileName
445 omniorbUserPath = os.getenv("OMNIORB_USER_PATH")
447 if omniorbUserPath is not None:
448 kwargs["with_username"]=True
450 last_running_config = generateFileName(omniorbUserPath, prefix="omniORB",
455 os.environ['OMNIORB_CONFIG'] = last_running_config
460 # Initialisation ORB and Naming Service
463 clt=orbmodule.client(args)
466 # Wake up session option
468 if args['wake_up_session']:
472 import SALOME_ModuleCatalog
473 import SALOME_Session_idl
474 session = clt.waitNS("/Kernel/Session",SALOME.Session)
475 status = session.GetStatSession()
477 from salome_utils import getPortNumber
478 port = getPortNumber()
481 msg += "Session GUI for port number %s is already active."%(port)
483 msg += "If you which to wake up another session,"
485 msg += "please use variable OMNIORB_CONFIG"
487 msg += "to get the correct session object in naming service."
488 sys.stdout.write(msg+"\n")
491 session.GetInterface()
492 args["session_object"] = session
495 # Save Naming service port name into
496 # the file args["ns_port_log_file"]
497 if args.has_key('ns_port_log_file'):
498 omniorbUserPath = os.getenv("OMNIORB_USER_PATH")
499 file_name = os.path.join(omniorbUserPath, args["ns_port_log_file"])
500 f = open(file_name, "w")
501 f.write(os.environ['NSPORT'])
504 # Launch Logger Server (optional)
505 # and wait until it is registered in naming service
509 myServer=LoggerServer(args)
511 clt.waitLogger("Logger")
513 # Notify Server launch
516 if sys.platform != "win32":
517 if verbose(): print "Notify Server to launch"
519 myServer=NotifyServer(args,modules_root_dir)
522 # set siman python path before the session server launching to import scripts inside python console
523 if simanStudyName(args):
524 # MPV: use os.environ here because session server is launched in separated process and sys.path is missed in this case
525 os.environ["PYTHONPATH"] = "/tmp/SimanSalome/" + args['siman_study'] + "/" + \
526 args['siman_scenario'] + "/" + args['siman_user'] + os.pathsep + os.environ["PYTHONPATH"];
528 # Launch Session Server (to show splash ASAP)
532 mySessionServ = SessionServer(args,args['modules'],modules_root_dir)
533 mySessionServ.setpath(modules_list,modules_root_dir)
537 # Launch Registry Server,
538 # and wait until it is registered in naming service
541 if ('registry' not in args['embedded']) | (args["gui"] == 0) :
542 myServer=RegistryServer(args)
544 if sys.platform == "win32":
545 clt.waitNS("/Registry")
547 clt.waitNSPID("/Registry",myServer.PID)
550 # Launch Catalog Server,
551 # and wait until it is registered in naming service
554 if ('moduleCatalog' not in args['embedded']) | (args["gui"] == 0):
555 cataServer=CatalogServer(args)
556 cataServer.setpath(modules_list,modules_root_dir)
558 import SALOME_ModuleCatalog
559 if sys.platform == "win32":
560 clt.waitNS("/Kernel/ModulCatalog",SALOME_ModuleCatalog.ModuleCatalog)
562 clt.waitNSPID("/Kernel/ModulCatalog",cataServer.PID,SALOME_ModuleCatalog.ModuleCatalog)
565 # Launch SalomeDS Server,
566 # and wait until it is registered in naming service
569 #print "ARGS = ",args
570 if ('study' not in args['embedded']) | (args["gui"] == 0):
572 myServer=SalomeDSServer(args)
574 if sys.platform == "win32":
575 clt.waitNS("/myStudyManager")
577 clt.waitNSPID("/myStudyManager",myServer.PID)
580 # Launch LauncherServer
583 myCmServer = LauncherServer(args)
584 myCmServer.setpath(modules_list,modules_root_dir)
588 # Launch ConnectionManagerServer
591 myConnectionServer = ConnectionManagerServer(args)
592 myConnectionServer.run()
595 from Utils_Identity import getShortHostName
597 if os.getenv("HOSTNAME") == None:
598 if os.getenv("HOST") == None:
599 os.environ["HOSTNAME"]=getShortHostName()
601 os.environ["HOSTNAME"]=os.getenv("HOST")
603 theComputer = getShortHostName()
606 # Launch local C++ Container (FactoryServer),
607 # and wait until it is registered in naming service
610 if ('cppContainer' in args['standalone']) | (args["gui"] == 0) :
611 myServer=ContainerCPPServer(args)
613 if sys.platform == "win32":
614 clt.waitNS("/Containers/" + theComputer + "/FactoryServer")
616 clt.waitNSPID("/Containers/" + theComputer + "/FactoryServer",myServer.PID)
619 # Launch local Python Container (FactoryServerPy),
620 # and wait until it is registered in naming service
623 if 'pyContainer' in args['standalone']:
624 raise Exception('Python containers no longer supported')
627 # Wait until Session Server is registered in naming service
635 import SALOME_ModuleCatalog
636 import SALOME_Session_idl
637 if sys.platform == "win32":
638 session=clt.waitNS("/Kernel/Session",SALOME.Session)
640 session=clt.waitNSPID("/Kernel/Session",mySessionServ.PID,SALOME.Session)
641 args["session_object"] = session
642 end_time = os.times()
644 print "Start SALOME, elapsed time : %5.1f seconds"% (end_time[4]
647 # ASV start GUI without Loader
649 # session.GetInterface()
652 # additionnal external python interpreters
658 nbaddi = args['interp']
661 traceback.print_exc()
662 print "-------------------------------------------------------------"
663 print "-- to get an external python interpreter:runSalome --interp=1"
664 print "-------------------------------------------------------------"
666 if verbose(): print "additional external python interpreters: ", nbaddi
668 for i in range(nbaddi):
670 anInterp=InterpServer(args)
673 # set PYTHONINSPECT variable (python interpreter in interactive mode)
675 os.environ["PYTHONINSPECT"]="1"
681 # siman session paramenters and checkout processing
682 if simanStudyName(args):
683 print '**********************************************'
684 print "Siman study name= '" + simanStudyName(args) + "'"
686 obj = clt.Resolve('myStudyManager')
687 myStudyManager = obj._narrow(SALOMEDS.StudyManager)
688 aNewStudy = myStudyManager.NewStudy(simanStudyName(args))
689 aSimS = myStudyManager.GetSimanStudy()
690 aSimS._set_StudyId(args['siman_study'])
691 aSimS._set_ScenarioId(args['siman_scenario'])
692 aSimS._set_UserId(args['siman_user'])
693 aSimS.CheckOut(aNewStudy)
694 # if session server is enabled, activate the created study
696 print "Activate the SIMAN study in the SALOME GUI"
697 obj = clt.Resolve('/Kernel/Session')
698 mySession = obj._narrow(SALOME.Session)
699 mySession.emitMessage("simanCheckoutDone " + simanStudyName(args))
700 print '**********************************************'
704 # -----------------------------------------------------------------------------
706 def useSalome(args, modules_list, modules_root_dir):
708 Launch all SALOME servers requested by args,
709 save list of process, give info to user,
710 show registered objects in Naming Service.
716 clt = startSalome(args, modules_list, modules_root_dir)
719 traceback.print_exc()
722 print "--- Error during Salome launch ---"
726 from addToKillList import addToKillList
727 from killSalomeWithPort import getPiDict
729 filedict = getPiDict(args['port'])
730 for pid, cmd in process_id.items():
731 addToKillList(pid, cmd, args['port'])
734 if verbose(): print """
735 Saving of the dictionary of Salome processes in %s
736 To kill SALOME processes from a console (kill all sessions from all ports):
738 To kill SALOME from the present interpreter, if it is not closed :
739 killLocalPort() --> kill this session
740 (use CORBA port from args of runSalome)
741 givenPortKill(port) --> kill a specific session with given CORBA port
742 killAllPorts() --> kill all sessions
744 runSalome, with --killall option, starts with killing
745 the processes resulting from the previous execution.
749 # Print Naming Service directory list
755 print " --- registered objects tree in Naming Service ---"
759 if not args['gui'] or not args['session_gui']:
760 if args['shutdown_servers']:
761 class __utils__(object):
762 def __init__(self, port):
764 import killSalomeWithPort
765 self.killSalomeWithPort = killSalomeWithPort
768 self.killSalomeWithPort.killMyPort(self.port)
771 args['shutdown_servers'] = __utils__(args['port'])
775 # run python scripts, passed as command line arguments
777 if args.has_key('pyscript'):
778 if args.has_key('gui') and args.has_key('session_gui'):
779 if not args['gui'] or not args['session_gui']:
780 toimport = args['pyscript']
782 command = formatScriptsAndArgs(toimport)
784 proc = subprocess.Popen(command, shell=True)
789 def execScript(script_path):
790 print 'executing', script_path
791 sys.path.insert(0, os.path.dirname(script_path))
792 execfile(script_path,globals())
795 # -----------------------------------------------------------------------------
797 def registerEnv(args, modules_list, modules_root_dir):
799 Register args, modules_list, modules_root_dir in a file
800 for further use, when SALOME is launched embedded in an other application.
802 if sys.platform == "win32":
803 fileEnv = os.getenv('TEMP')
807 fileEnv += os.getenv('USER') + "_" + str(args['port']) \
808 + '_' + args['appname'].upper() + '_env'
809 fenv=open(fileEnv,'w')
810 pickle.dump((args, modules_list, modules_root_dir),fenv)
812 os.environ["SALOME_LAUNCH_CONFIG"] = fileEnv
814 # -----------------------------------------------------------------------------
817 """Salome Launch, when embedded in other application"""
818 fileEnv = os.environ["SALOME_LAUNCH_CONFIG"]
819 fenv=open(fileEnv,'r')
820 args, modules_list, modules_root_dir = pickle.load(fenv)
823 from searchFreePort import searchFreePort
824 searchFreePort(args, 0)
825 clt = useSalome(args, modules_list, modules_root_dir)
828 # -----------------------------------------------------------------------------
831 """Salome launch as a main application"""
834 if not os.getenv("OMNIORB_USER_PATH"):
835 homePath = os.path.realpath(os.path.expanduser('~'))
836 #defaultOmniorbUserPath = os.path.join(homePath, ".salomeConfig/USERS")
837 defaultOmniorbUserPath = homePath
838 if os.getenv("APPLI"):
839 defaultOmniorbUserPath = os.path.join(homePath, os.getenv("APPLI"), "USERS")
840 os.environ["OMNIORB_USER_PATH"] = defaultOmniorbUserPath
844 from salome_utils import getHostName
845 print "runSalome running on %s" % getHostName()
846 args, modules_list, modules_root_dir = setenv.get_config()
850 if args.has_key('save_config'):
851 save_config = args['save_config']
854 if args['wake_up_session']:
858 from searchFreePort import searchFreePort
859 searchFreePort(args, save_config, args.get('useport'))
863 setenv.set_env(args, modules_list, modules_root_dir)
864 clt = useSalome(args, modules_list, modules_root_dir)
867 # -----------------------------------------------------------------------------
869 def foreGround(clt, args):
871 if "session_object" not in args:
873 session = args["session_object"]
875 # Wait until gui is arrived
884 status = session.GetStatSession()
885 gui_detected = status.activeGUI
890 from time import sleep
900 from salome_utils import getPortNumber
901 port = getPortNumber()
904 if sys.platform == "win32":
905 server.CMD = [os.getenv("PYTHONBIN"), "-m", "killSalomeWithPort", "--spy", "%s"%(os.getpid()), "%s"%(port)]
907 server.CMD = ["killSalomeWithPort.py", "--spy", "%s"%(os.getpid()), "%s"%(port)]
909 # os.system("killSalomeWithPort.py --spy %s %s &"%(os.getpid(), port))
915 status = session.GetStatSession()
916 assert status.activeGUI
919 from time import sleep
923 except KeyboardInterrupt:
924 from killSalomeWithPort import killMyPort
934 test = args['gui'] and args['session_gui']
935 test = test or args['wake_up_session']
937 # The next test covers the --pinter option or var PYTHONINSPECT setted
939 test = test and not os.environ.get('PYTHONINSPECT')
941 # The next test covers the python -i $KERNEL_ROOT_DIR/bin/salome/runSalome.py case
944 from ctypes import POINTER, c_int, cast, pythonapi
945 iflag_ptr = cast(pythonapi.Py_InteractiveFlag, POINTER(c_int))
946 test = test and not iflag_ptr.contents.value
950 test = test and os.getenv("SALOME_TEST_MODE", "0") != "1"
951 test = test and args['foreground']
954 foreGround(clt, args)
960 # -----------------------------------------------------------------------------
962 if __name__ == "__main__":