#!/usr/bin/env python
-import os, string
+import os, string, sys
-from killSalomeWithPort import killSalome
+from killSalomeWithPort import killMyPort
-user = os.getenv('USER')
-for file in os.listdir("/tmp"):
- l = string.split(file, "_")
- if len(l) >= 4:
- if file[:len(user)] == user:
- if l[len(l)-2] == "SALOME" and l[len(l)-1] == "pidict":
- killSalome(l[len(l)-3])
- pass
+def killAllPorts():
+ user = os.getenv('USER')
+ for file in os.listdir("/tmp"):
+ l = string.split(file, "_")
+ if len(l) >= 4:
+ if file[:len(user)] == user:
+ if l[len(l)-2] == "SALOME" and l[len(l)-1] == "pidict":
+ killMyPort(l[len(l)-3])
+ pass
+
+if sys.argv[0] == "killSalome.py":
+ killAllPorts()
import os, sys, pickle, signal, commands
########## kills all salome processes with the given port ##########
-def killSalome(port):
+def killMyPort(port):
filedict='/tmp/'+os.getenv('USER')+"_"+port+'_SALOME_pidict'
found = 0
try:
for process_id in process_ids:
for pid, cmd in process_id.items():
+ print "stop process %s : %s"% (pid, cmd[0])
try:
os.kill(int(pid),signal.SIGKILL)
except:
if sys.argv[0] == "killSalomeWithPort.py":
for port in sys.argv[1:]:
- killSalome(port)
+ killMyPort(port)
import os, glob, string, sys
import xml.sax
+# -----------------------------------------------------------------------------
+
### xml reader for launch configuration file usage
+
class xml_parser:
def __init__(self, fileName):
self.space = []
self.opts[key]=[]
pass
self.opts[key].append(attrs.getValue("name"))
+ elif self.space == ["Configuration-list","embedded-list"]:
+ self.opts["embedded"] = []
+ pass
+ elif self.space == ["Configuration-list","standalone-list"]:
+ self.opts["standalone"] = []
+ pass
elif self.space == ["Configuration-list","containers-list"]:
self.opts["containers"] = []
pass
#print "Characters content:",content
if self.current:
self.opts[self.current] = self.CorrectBoolean(content)
+ elif self.space == ["Configuration-list","embedded-list", "embeddedserver"]:
+ self.opts["embedded"].append(content)
+ elif self.space == ["Configuration-list","standalone-list", "standaloneserver"]:
+ self.opts["standalone"].append(content)
elif self.space == ["Configuration-list","containers-list", "containertype"]:
self.opts["containers"].append(content)
pass
self.read = None
pass
+# -----------------------------------------------------------------------------
+
### searching for launch configuration file : $HOME/.$(application_name)/$(application_name).launch
+
appname = None
filename = None
for bindir in glob.glob(os.environ["KERNEL_ROOT_DIR"]+"/bin/*"):
pass
### get options from launch configuration file
+
try:
p = xml_parser(filename)
except:
args["appname"] = appname
### searching for my port
+
my_port = 2809
try:
file = open(os.environ["OMNIORB_CONFIG"], "r")
args["port"] = my_port
+# -----------------------------------------------------------------------------
+
### command line options reader
+
def options_parser(line):
source = line
list = []
list = []
pass
+ print "source=",source
+
result = {}
i = 0
while i < len(source):
pass
return result
-### read command-line options
+# -----------------------------------------------------------------------------
+
+### read command-line options : each arg given in command line supersedes arg from xml config file
+
try:
opts = options_parser(sys.argv[1:])
+ print "opts=",opts
kernel_root_dir=os.environ["KERNEL_ROOT_DIR"]
except:
opts["h"] = 1
pass
### check all options are right
+
+opterror=0
for opt in opts:
- if not opt in ("h","g","l","x","m","c","p","k","t"):
- opts["h"] = 1
+ if not opt in ("h","g","l","x","m","e","s","c","p","k","t"):
+ print "command line error: -", opt
+ opterror=1
+if opterror == 1:
+ opts["h"] = 1
if opts.has_key("h"):
print """USAGE: runSalome.py [options]
--xterm or -x : les serveurs ouvrent une fenêtre xterm et les messages sont affichés dans cette fenêtre
--modules=module1,module2,... : où modulen est le nom d'un module Salome à charger dans le catalogue
or -m=module1,module2,...
- --containers=cpp,python,superv: lancement des containers cpp, python et de supervision
- or -c=cpp,python,superv
+ --embedded=registry,study,moduleCatalog,cppContainer
+ or -e=registry,study,moduleCatalog,cppContainer
+ : serveurs CORBA embarqués (par defaut: registry,study,moduleCatalog,cppContainer)
+ : (logger,pyContainer,supervContainer ne peuvent pas être embarqués
+ --standalone=registry,study,moduleCatalog,cppContainer,pyContainer,supervContainer
+ or -s=registry,study,moduleCatalog,cppContainer,pyContainer,supervContainer
+ : executables serveurs CORBA indépendants (par défaut: pyContainer,supervContainer)
+ --containers=cpp,python,superv: (obsolete) lancement des containers cpp, python et de supervision
+ or -c=cpp,python,superv : = on prend les defauts de -e et -s
--portkill or -p : kill the salome with current port
--killall or -k : kill salome
args['xterm'] = 1
elif opt == 'm':
args['modules'] = opts['m']
+ elif opt == 'e':
+ args['embedded'] = opts['e']
+ elif opt == 's':
+ args['standalone'] = opts['s']
elif opt == 'c':
args['containers'] = opts['c']
elif opt == 'p':
if 't' in opts:
args['gui'] = 0
pass
+
+print "args=",args
done
if [ $# -ne 0 ] ; then
- python ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py $*
+ python -i ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py $*
else
python ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py
fi
-#python -i ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py --gui --modules=GEOM --xterm --containers=cpp,python --killall
-#python -i ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py --gui --modules=GEOM,SMESH,VISU,SUPERV,MED --xterm --containers=cpp,python --killall
-#python -i ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py --gui --modules=GEOM,SMESH,VISU,SUPERV,MED --logger --xterm
-#python -i ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py --modules=GEOM,SMESH,VISU,SUPERV,MED
-#python -i ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py --help
-
+# -----------------------------------------------------------------------------
+# examples:
+# ---------
+# $: ${KERNEL_ROOT_DIR}/bin/salome/runSalome
+#
+# parameters read from $HOME/.salome/salome.launch
+# if the config file does not exist, it is created with default values
+#
+#
+# $: ${KERNEL_ROOT_DIR}/bin/salome/runSalome --modules=GEOM,SMESH,VISU,SUPERV,MED --embedded=registry,study,moduleCatalog,cppContainer --standalone=pyContainer,supervContainer --xterm --killall
+#
+# parameter from command line supersedes thoses from $HOME/.salome/salome.launch
+#
+# Some CORBA servers could be launched in the SALOME_Session_Server
+# (embedded = same process) or in a separate process (standalone):
+# --> registry,study,moduleCatalog,cppContainer
+# Other CORBA servers could only be launched in separate process (standalone):
+# --> pyContainer,supervContainer
+#
+# $: ${KERNEL_ROOT_DIR}/bin/salome/runSalome -h
+# help
# -----------------------------------------------------------------------------
#
# l'option -i permet de garder l'interpreteur python ouvert :
args = launchConfigureParser.args
### kill servers if it is need
-if args['killall']:
- import killSalome
-elif args['portkill']:
- from killSalomeWithPort import killSalome
- filedict='/tmp/'+os.getenv('USER')+"_"+str(args['port'])+'_'+args['appname'].upper()+'_pidict'
+
+from killSalome import killAllPorts
+
+def killLocalPort():
+ from killSalomeWithPort import killMyPort
+ my_port=str(args['port'])
try:
- killSalome(my_port)
+ killMyPort(my_port)
except:
+ print "problem in killLocalPort()"
pass
pass
+
+if args['killall']:
+ killAllPorts()
+elif args['portkill']:
+ killLocalPort()
# -----------------------------------------------------------------------------
#
CMD=CMD+['GUI']
class SessionServer(Server):
- #CMD=['SALOME_Session_Server']
- SCMD1=['SALOME_Session_Server',
- '--with','Registry','(','--salome_session','theSession',')',
- '--with','ModuleCatalog','(','-common']
- SCMD2=['-personal','${HOME}/Salome/resources/CatalogModulePersonnel.xml',')',
- '--with','SALOMEDS','(',')',
- '--with','Container','(','FactoryServer',')']
+ SCMD1=['SALOME_Session_Server']
+ SCMD2=[]
+ if 'registry' in args['embedded']:
+ SCMD1+=['--with','Registry','(','--salome_session','theSession',')']
+ if 'moduleCatalog' in args['embedded']:
+ SCMD1+=['--with','ModuleCatalog','(','-common']
+ SCMD2+=['-personal','${HOME}/Salome/resources/CatalogModulePersonnel.xml',')']
+ if 'study' in args['embedded']:
+ SCMD2+=['--with','SALOMEDS','(',')']
+ if 'cppContainer' in args['embedded']:
+ SCMD2+=['--with','Container','(','FactoryServer',')']
+
def setpath(self,modules_list):
cata_path=[]
list_modules = modules_list[:]
module_cata=module+"Catalog.xml"
print " ", module_cata
cata_path.extend(glob.glob(os.path.join(module_root_dir,"share",args['appname'],"resources",module_cata)))
- self.CMD=self.SCMD1 + [string.join(cata_path,':')] + self.SCMD2
+ if 'moduleCatalog' in args['embedded']:
+ self.CMD=self.SCMD1 + [string.join(cata_path,':')] + self.SCMD2
+ else:
+ self.CMD=self.SCMD1 + self.SCMD2
class NotifyServer(Server):
myLogName = os.environ["LOGNAME"]
NotifyServer().run()
#
- # Lancement Registry Server
- #
-
- #RegistryServer().run()
-
- #
- # Attente de la disponibilité du Registry dans le Naming Service
- #
-
- #clt.waitNS("/Registry")
-
- #
- # Lancement Catalog Server
+ # Lancement Registry Server, attente de la disponibilité du Registry dans le Naming Service
#
-
- #cataServer=CatalogServer()
- #cataServer.setpath(modules_list)
- #cataServer.run()
+ if 'registry' not in args['embedded']:
+ RegistryServer().run()
+ clt.waitNS("/Registry")
#
- # Attente de la disponibilité du Catalog Server dans le Naming Service
+ # Lancement Catalog Server, attente de la disponibilité du Catalog Server dans le Naming Service
#
- #import SALOME_ModuleCatalog
- #clt.waitNS("/Kernel/ModulCatalog",SALOME_ModuleCatalog.ModuleCatalog)
+ if 'moduleCatalog' not in args['embedded']:
+ cataServer=CatalogServer()
+ cataServer.setpath(modules_list)
+ cataServer.run()
+ import SALOME_ModuleCatalog
+ clt.waitNS("/Kernel/ModulCatalog",SALOME_ModuleCatalog.ModuleCatalog)
#
- # Lancement SalomeDS Server
+ # Lancement SalomeDS Server, attente de la disponibilité du SalomeDS dans le Naming Service
#
os.environ["CSF_PluginDefaults"]=os.path.join(modules_root_dir["KERNEL"],"share",args['appname'],"resources")
os.environ["CSF_SALOMEDS_ResourcesDefaults"]=os.path.join(modules_root_dir["KERNEL"],"share",args['appname'],"resources")
- #SalomeDSServer().run()
if "GEOM" in modules_list:
print "GEOM OCAF Resources"
os.environ["CSF_GEOMDS_ResourcesDefaults"]=os.path.join(modules_root_dir["GEOM"],"share",args['appname'],"resources")
-
- #
- # Attente de la disponibilité du SalomeDS dans le Naming Service
- #
-
- #clt.waitNS("/myStudyManager")
+ if 'study' not in args['embedded']:
+ SalomeDSServer().run()
+ clt.waitNS("/myStudyManager")
#
# Lancement Session Server
mySessionServ=SessionServer()
mySessionServ.setpath(modules_list)
mySessionServ.run()
- #SessionServer().run()
#
# Attente de la disponibilité du Session Server dans le Naming Service
theComputer = computerSplitName[0]
#
- # Lancement Container C++ local
+ # Lancement Container C++ local, attente de la disponibilité du Container C++ local dans le Naming Service
#
- #if 'cpp' in args['containers']:
- #ContainerCPPServer().run()
- #
- # Attente de la disponibilité du Container C++ local dans le Naming Service
- #
-
- #clt.waitNS("/Containers/" + theComputer + "/FactoryServer")
+ if 'cppContainer' in args['standalone']:
+ ContainerCPPServer().run()
+ clt.waitNS("/Containers/" + theComputer + "/FactoryServer")
#
- # Lancement Container Python local
+ # Lancement Container Python local, attente de la disponibilité du Container Python local dans le Naming Service
#
- if 'python' in args['containers']:
+ if 'pyContainer' in args['standalone']:
ContainerPYServer().run()
-
- #
- # Attente de la disponibilité du Container Python local dans le Naming Service
- #
-
clt.waitNS("/Containers/" + theComputer + "/FactoryServerPy")
- if 'superv' in args['containers']:
-
- #
- # Lancement Container Supervision local
- #
-
- ContainerSUPERVServer().run()
-
- #
- # Attente de la disponibilité du Container Supervision local dans le Naming Service
- #
-
- clt.waitNS("/Containers/" + theComputer + "/SuperVisionContainer")
-
-
#
- # Activation du GUI de Session Server
+ # Lancement Container Supervision local, attente de la disponibilité du Container Supervision local dans le Naming Service
#
-
- #session.GetInterface()
+
+ if 'supervContainer' in args['standalone']:
+ ContainerSUPERVServer().run()
+ clt.waitNS("/Containers/" + theComputer + "/SuperVisionContainer")
end_time = os.times()
print
pickle.dump(process_ids,fpid)
fpid.close()
- print
- print "Saving of the dictionary of Salome processes in ", filedict
- print "To kill SALOME processes launch : python killSalome.py from"
- print "a console or killSalome() from the present interpreter, if it is not closed."
- print
- print "runSalome, with --killall option, starts with killing the processes resulting from the previous execution."
- print
- print "To launch only GUI only execute startGUI() from the present interpreter,"
- print "if it is not closed."
+ print """
+ Saving of the dictionary of Salome processes in %s
+ To kill SALOME processes from a console (kill all sessions from all ports):
+ python killSalome.py
+ To kill SALOME from the present interpreter, if it is not closed :
+ killLocalPort() --> kill this session
+ killAllPorts() --> kill all sessions
+
+ runSalome, with --killall option, starts with killing the processes resulting from the previous execution.
+ """%filedict
#
# Impression arborescence Naming Service
<module name="COMPONENT"/>
<module name="PYCALCULATOR"/>
</modules-list>
- <containers-list>
- <containertype>cpp</containertype>
- <containertype>python</containertype>
- <containertype>superv</containertype>
- </containers-list>
+ <embedded-list>
+ <embeddedserver>registry</embeddedserver>
+ <embeddedserver>study</embeddedserver>
+ <embeddedserver>moduleCatalog</embeddedserver>
+ <embeddedserver>cppContainer</embeddedserver>
+ </embedded-list>
+ <standalone-list>
+ <standaloneserver>pyContainer</standaloneserver>
+ <standaloneserver>supervContainer</standaloneserver>
+ </standalone-list>
</Configuration-list>