From: yfr Date: Thu, 17 Jun 2004 09:19:04 +0000 (+0000) Subject: DCQ : Merge with Ecole_Ete_a6. X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ac2ad9920aca0ee2622e6e1e7e9965de401ca2f1;p=modules%2Fyacs.git DCQ : Merge with Ecole_Ete_a6. --- diff --git a/bin/VERSION b/bin/VERSION index 037ad6d66..699b2270c 100755 --- a/bin/VERSION +++ b/bin/VERSION @@ -1 +1 @@ -THIS IS SALOME - KERNEL VERSION: 1.4.0 +THIS IS SALOME - KERNEL VERSION: 2.0.0 diff --git a/bin/killSalome.py b/bin/killSalome.py index 814420dfa..96e923980 100755 --- a/bin/killSalome.py +++ b/bin/killSalome.py @@ -1,40 +1,17 @@ #!/usr/bin/env python - -import sys,os,pickle,signal - -process_id={} - -# ----------------------------------------------------------------------------- -# -# Fonction d'arrêt de salome -# - -def killSalome(): - print "arret des serveurs SALOME" - for pid, cmd in process_id.items(): - print "arret du process %s : %s"% (pid, cmd[0]) - try: - os.kill(pid,signal.SIGKILL) - except: - print " ------------------ process %s : %s inexistant"% (pid, cmd[0]) - print "arret du naming service" - os.system("killall -9 omniNames") - -# ----------------------------------------------------------------------------- - -filedict='/tmp/'+os.getenv('USER')+'_SALOME_pidict' -#filedict='/tmp/'+os.getlogin()+'_SALOME_pidict' -try: - fpid=open(filedict, 'r') -except: - print "le fichier %s des process SALOME n'est pas accessible"% filedict - sys.exit(1) - -process_id=pickle.load(fpid) -fpid.close() - -killSalome() - -os.remove(filedict) - - +import os, string, sys + +from killSalomeWithPort import killMyPort + +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 __name__ == "__main__": + killAllPorts() diff --git a/bin/killSalomeWithPort.py b/bin/killSalomeWithPort.py new file mode 100755 index 000000000..7c8dcd2ed --- /dev/null +++ b/bin/killSalomeWithPort.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python +import os, sys, pickle, signal, commands + +########## kills all salome processes with the given port ########## +def killMyPort(port): + filedict='/tmp/'+os.getenv('USER')+"_"+port+'_SALOME_pidict' + found = 0 + try: + fpid=open(filedict, 'r') + found = 1 + except: + print "le fichier %s des process SALOME n'est pas accessible"% filedict + pass + + if found: + a = os.system("pid=`ps -eo pid,command | egrep \"[0-9] omniNames -start "+str(port)+"\" | sed -e \"s%[^0-9]*\([0-9]*\) .*%\\1%g\"`; kill -9 $pid") + try: + process_ids=pickle.load(fpid) + fpid.close() + 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: + print " ------------------ process %s : %s inexistant"% (pid, cmd[0]) + pass + pass + except: + pass + os.remove(filedict) + pid = commands.getoutput("ps -eo pid,command | egrep \"[0-9] omniNames -start "+str(port)+"\" | sed -e \"s%[^0-9]*\([0-9]*\) .*%\\1%g\"") + while pid != "": + a = os.system("pid=`ps -eo pid,command | egrep \"[0-9] omniNames -start "+str(port)+"\" | sed -e \"s%[^0-9]*\([0-9]*\) .*%\\1%g\"`; kill -9 $pid") + pid = commands.getoutput("ps -eo pid,command | egrep \"[0-9] omniNames -start "+str(port)+"\" | sed -e \"s%[^0-9]*\([0-9]*\) .*%\\1%g\"") + + +if __name__ == "__main__": + for port in sys.argv[1:]: + killMyPort(port) diff --git a/bin/launchConfigureParser.py b/bin/launchConfigureParser.py new file mode 100755 index 000000000..e1d63aeb9 --- /dev/null +++ b/bin/launchConfigureParser.py @@ -0,0 +1,283 @@ +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 = {} + parser = xml.sax.make_parser() + parser.setContentHandler(self) + parser.parse(fileName) + pass + + def CorrectBoolean(self, str): + if str in ("yes", "y", "1"): + return 1 + elif str in ("no", "n", "0"): + return 0 + else: + return str + pass + + def startElement(self, name, attrs): + #print "startElement name=",name + #print "startElement attrs=",attrs.getNames() + self.space.append(name) + self.current = None + + if self.space[:2] == ["Configuration-list","launchoptions"] and len(self.space) == 3: + self.current = name + elif self.space == ["Configuration-list","modules-list"]: + self.opts["modules"] = [] + elif self.space == ["Configuration-list","modules-list","module"] and "name" in attrs.getNames(): + for field in attrs.getNames(): + if field == "name": + self.currentModuleName = str(attrs.getValue("name")) + self.opts["modules"].append(self.currentModuleName) + else: + self.opts[str(attrs.getValue("name"))+"_"+str(field)] = self.CorrectBoolean(attrs.getValue(field)) + pass + pass + elif self.space == ["Configuration-list","modules-list","module","plugin"] and "name" in attrs.getNames(): + key = str(self.currentModuleName)+"_plugins" + if not self.opts.has_key("key"): + 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 + pass + + def endElement(self, name): + p = self.space.pop() + self.current = None + pass + + def characters(self, content): + #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 + + def processingInstruction(self, target, data): + pass + + def setDocumentLocator(self, locator): + pass + + def startDocument(self): + self.read = None + pass + + def endDocument(self): + 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/*"): + appname = string.split(bindir, "/").pop() + print 'Application name: "'+appname+'"' + filename = os.environ["HOME"]+"/."+appname+"/"+appname+".launch" + if not os.path.exists(filename) and \ + not os.path.exists(os.environ["KERNEL_ROOT_DIR"]+"/bin/"+appname+"/"+appname+".launch"): + filename = None + else: + break + pass +if not appname: + print "Can not find application name" + if not os.have_key("KERNEL_ROOT_DIR"): + print "KERNEL_ROOT_DIR environment variable must be set" + pass + sys.exit(1); +elif not filename or not os.path.exists(filename): + filename = os.environ["HOME"]+"/."+appname+"/"+appname+".launch" + print "Launch configuration file does not exist. Create default:",filename + os.system("mkdir -p "+os.environ["HOME"]+"/."+appname) + os.system("cp -f "+os.environ["KERNEL_ROOT_DIR"]+"/bin/"+appname+"/"+appname+".launch "+filename) + pass + +### get options from launch configuration file + +try: + p = xml_parser(filename) +except: + print 'Can not read launch configuration file ', filename + filename = None + pass + +if filename: + args = p.opts +else: + args = {} + pass + +# --- args completion +for aKey in ("containers","embedded","key","modules","standalone"): + if not args.has_key(aKey): + args[aKey]=[] +for aKey in ("gui","logger","xterm","portkill","killall"): + if not args.has_key(aKey): + args[aKey]=0 +args["appname"] = appname + +### searching for my port + +my_port = 2809 +try: + file = open(os.environ["OMNIORB_CONFIG"], "r") + s = file.read() + while len(s): + l = string.split(s, ":") + if string.split(l[0], " ")[0] == "ORBInitRef": + my_port = int(l[len(l)-1]) + pass + s = file.read() + pass +except: + pass + +args["port"] = my_port + +# ----------------------------------------------------------------------------- + +### command line options reader + +def options_parser(line): + source = line + list = [] + for delimiter in [" ", ",", "="]: + for o in source: + list += string.split(o, delimiter) + pass + source = list + list = [] + pass + + print "source=",source + + result = {} + i = 0 + while i < len(source): + if source[i][0] != '-': + key = None + elif source[i][1] == '-': + key = source[i][2] + else: + key = source[i][1] + pass + + result[key] = [] + if key: + i += 1 + pass + while i < len(source) and source[i][0] != '-': + result[key].append(source[i]) + i += 1 + pass + pass + return result + +# ----------------------------------------------------------------------------- + +### 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","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] + [command line options] : + --help or -h : print this help + --gui or -g : lancement du GUI + --terminal -t : launching without gui (to deny --gui) + --logger or -l : redirection des messages dans un fichier + --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,... + --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 + + La variable d'environnement _ROOT_DIR doit etre préalablement + positionnée (modulen doit etre en majuscule). + KERNEL_ROOT_DIR est obligatoire. + """ + sys.exit(1) + pass + +### apply command-line options to the arguments +for opt in opts: + if opt == 'g': + args['gui'] = 1 + elif opt == 'l': + args['logger'] = 1 + elif opt == 'x': + 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': + args['portkill'] = 1 + elif opt == 'k': + args['killall'] = 1 + pass + pass + +# 'terminal' must be processed in the end: to deny any 'gui' options +if 't' in opts: + args['gui'] = 0 + pass + +print "args=",args diff --git a/bin/orbmodule.py b/bin/orbmodule.py index 1154b0101..a96bc9847 100755 --- a/bin/orbmodule.py +++ b/bin/orbmodule.py @@ -24,6 +24,7 @@ class NamingServer(Server): USER=os.getenv('USER') if USER is None: USER='anonymous' + os.system("mkdir -m 777 -p /tmp/logs") LOGDIR="/tmp/logs/" + USER os.system("mkdir -m 777 -p " + LOGDIR) CMD="runNS.sh > " + LOGDIR + "/salomeNS.log 2>&1" diff --git a/bin/runNS.sh b/bin/runNS.sh index 226bc9be6..76b7452bf 100755 --- a/bin/runNS.sh +++ b/bin/runNS.sh @@ -11,14 +11,15 @@ Username=`/usr/bin/whoami` # clear log files -mkdir -m 775 ${BaseDir}/logs +mkdir -m 777 ${BaseDir}/logs mkdir ${BaseDir}/logs/${Username} touch ${BaseDir}/logs/${Username}/dummy \rm -f ${BaseDir}/logs/${Username}/omninames* ${BaseDir}/logs/${Username}/dummy ${BaseDir}/logs/${Username}/*.log echo "Name Service... " - -omniNames -start -logdir ${BaseDir}/logs/${Username} & +aSedCommand="s/ORBInitRef NameService=corbaname::`hostname`:\([[:digit:]]*\)/\1/" +aPort=`sed -e"$aSedCommand" $OMNIORB_CONFIG` +omniNames -start $aPort -logdir ${BaseDir}/logs/${Username} & # In LifeCycleCORBA, FactoryServer is started with rsh on the requested # computer if this Container does not exist. Default is localhost. diff --git a/bin/runSalome b/bin/runSalome index 3a3d0e2d2..9577ea58e 100755 --- a/bin/runSalome +++ b/bin/runSalome @@ -1,10 +1,47 @@ -#!/bin/sh +#!/bin/bash -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 +NSPORT=2809 +echo -n "Searching for free port for the SALOME Naming Service: " +while [ ${NSPORT} -lt 3000 ]; do + NSPORT=`expr ${NSPORT} + 1` + aRes=`netstat -ltn | grep -E :${NSPORT}` + if [ -z "$aRes" ]; then +cat > ${OMNIORB_CONFIG} < 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 : diff --git a/bin/runSalome.csh b/bin/runSalome.csh new file mode 100755 index 000000000..73798c25c --- /dev/null +++ b/bin/runSalome.csh @@ -0,0 +1,3 @@ +#!/bin/csh -f + +runSalome --gui --modules=GEOM,SMESH,VISU,SUPERV,MED --containers=cpp,python --killall diff --git a/bin/runSalome.py b/bin/runSalome.py index d8f148c90..d39035584 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -1,145 +1,102 @@ #!/usr/bin/env python -usage="""USAGE: runSalome.py [options] - -[command line options] : ---help : affichage de l'aide ---gui : lancement du GUI ---logger : redirection des messages dans un fichier ---xterm : 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 ---containers=cpp,python,superv: lancement des containers cpp, python et de supervision ---killall : arrêt des serveurs de salome - - La variable d'environnement _ROOT_DIR doit etre préalablement - positionnée (modulen doit etre en majuscule). - KERNEL_ROOT_DIR est obligatoire. -""" - +import sys, os, string, glob, time, pickle + +### read launch configure xml file and command line options +import launchConfigureParser +args = launchConfigureParser.args + +### kill servers if it is need + +from killSalome import killAllPorts + +def killLocalPort(): + from killSalomeWithPort import killMyPort + my_port=str(args['port']) + try: + killMyPort(my_port) + except: + print "problem in killLocalPort()" + pass + pass + +if args['killall']: + killAllPorts() +elif args['portkill']: + killLocalPort() + # ----------------------------------------------------------------------------- # -# Fonction d'arrêt de salome +# Fonctions helper pour ajouter des variables d'environnement # -def killSalome(): - print "arret des serveurs SALOME" - for pid, cmd in process_id.items(): - print "arret du process %s : %s"% (pid, cmd[0]) - try: - os.kill(pid,signal.SIGKILL) - except: - print " ------------------ process %s : %s inexistant"% (pid, cmd[0]) - print "arret du naming service" - os.system("killall -9 omniNames") - -# ----------------------------------------------------------------------------- -# -# Fonction message -# +def add_path(directory, variable_name): + if not os.environ.has_key(variable_name): + os.environ[variable_name] = "" + pass + os.environ[variable_name]=directory + ":" + os.environ[variable_name] + if variable_name=="PYTHONPATH": + sys.path[:0]=[directory] -def message(code, msg=''): - if msg: print msg - sys.exit(code) - -import sys,os,string,glob,time,signal,pickle,getopt - -init_time=os.times() -opts, args=getopt.getopt(sys.argv[1:], 'hmglxck:', ['help','modules=','gui','logger','xterm','containers=','killall']) -modules_root_dir={} -process_id={} -liste_modules={} -liste_containers={} -with_gui=0 -with_logger=0 -with_xterm=0 - -with_container_cpp=0 -with_container_python=0 -with_container_superv=0 - -try: - for o, a in opts: - if o in ('-h', '--help'): - print usage - sys.exit(1) - elif o in ('-g', '--gui'): - with_gui=1 - elif o in ('-l', '--logger'): - with_logger=1 - elif o in ('-x', '--xterm'): - with_xterm=1 - elif o in ('-m', '--modules'): - liste_modules = [x.upper() for x in a.split(',')] - elif o in ('-c', '--containers'): - liste_containers = [x.lower() for x in a.split(',')] - for r in liste_containers: - if r not in ('cpp', 'python', 'superv'): - message(1, 'Invalid -c/--containers option: %s' % a) - if 'cpp' in liste_containers: - with_container_cpp=1 - else: - with_container_cpp=0 - if 'python' in liste_containers: - with_container_python=1 - else: - with_container_python=0 - if 'superv' in liste_containers: - with_container_superv=1 - else: - with_container_superv=0 - elif o in ('-k', '--killall'): - filedict='/tmp/'+os.getenv('USER')+'_SALOME_pidict' - #filedict='/tmp/'+os.getlogin()+'_SALOME_pidict' - found = 0 - try: - fpid=open(filedict, 'r') - found = 1 - except: - print "le fichier %s des process SALOME n'est pas accessible"% filedict - - if found: - process_id=pickle.load(fpid) - fpid.close() - killSalome() - process_id={} - os.remove(filedict) - -except getopt.error, msg: - print usage - sys.exit(1) +init_time = os.times() # ----------------------------------------------------------------------------- # -# Vérification des variables d'environnement +# Check variables _ROOT_DIR and set list of used modules (without KERNEL) +# Add to the PATH-variables modules' specific paths # -try: - kernel_root_dir=os.environ["KERNEL_ROOT_DIR"] - modules_root_dir["KERNEL"]=kernel_root_dir -except: - print usage - sys.exit(1) - -for module in liste_modules : - try: - module=module.upper() - module_root_dir=os.environ[module +"_ROOT_DIR"] - modules_root_dir[module]=module_root_dir - except: - print usage - sys.exit(1) - -# il faut KERNEL en premier dans la liste des modules -# - l'ordre des modules dans le catalogue sera identique -# - la liste des modules presents dans le catalogue est exploitée pour charger les modules CORBA python, -# il faut charger les modules python du KERNEL en premier - -if "KERNEL" in liste_modules:liste_modules.remove("KERNEL") -liste_modules[:0]=["KERNEL"] -#print liste_modules -#print modules_root_dir - -os.environ["SALOMEPATH"]=":".join(modules_root_dir.values()) -if "SUPERV" in liste_modules:with_container_superv=1 +modules_list = [] +if args.has_key("modules"): + modules_list += args["modules"] +modules_list[:0] = ["KERNEL"] # KERNEL must be last in the list to locate it at the first place in PATH variables +modules_list.reverse() + +modules_root_dir = {} +modules_root_dir_list = [] +python_version="python%d.%d" % sys.version_info[0:2] + +to_remove_list=[] +for module in modules_list : + module_variable=module.upper()+"_ROOT_DIR" + if not os.environ.has_key(module_variable): + print "*******************************************************************************" + print "*" + print "* Environment variable",module_variable,"must be set" + print "* Module", module, "will be not available" + print "*" + print "*******************************************************************************" + to_remove_list.append(module) + continue + pass + module_root_dir = os.environ[module_variable] + modules_root_dir[module]=module_root_dir + modules_root_dir_list[:0] = [module_root_dir] + add_path(os.path.join(module_root_dir,"lib",args['appname']), "LD_LIBRARY_PATH") + add_path(os.path.join(module_root_dir,"bin",args['appname']), "PATH") + if os.path.exists(module_root_dir + "/examples") : + add_path(os.path.join(module_root_dir,"examples"), "PYTHONPATH") + +for to_remove in to_remove_list: + modules_list.remove(to_remove) + +while "KERNEL" in modules_list: + modules_list.remove("KERNEL") + pass + +# KERNEL must be last in the list to locate it at the first place in PYTHONPATH variable +list_modules = modules_list[:] + ["KERNEL"] +for module in list_modules: + module_root_dir = modules_root_dir[module] + add_path(os.path.join(module_root_dir,"bin",args['appname']), "PYTHONPATH") + add_path(os.path.join(module_root_dir,"lib",python_version,"site-packages",args['appname']), "PYTHONPATH") + add_path(os.path.join(module_root_dir,"lib",args['appname']), "PYTHONPATH") + add_path(os.path.join(module_root_dir,"lib",python_version,"site-packages",args['appname'],"shared_modules"), "PYTHONPATH") + +#os.environ["SALOMEPATH"]=":".join(modules_root_dir.values()) +os.environ["SALOMEPATH"]=":".join(modules_root_dir_list) +if "SUPERV" in modules_list and not 'superv' in args['standalone']: + args['standalone'].append("superv") + pass # ----------------------------------------------------------------------------- @@ -149,33 +106,36 @@ if "SUPERV" in liste_modules:with_container_superv=1 class Server: CMD=[] - if with_xterm: + if args['xterm']: ARGS=['xterm', '-iconic', '-sb', '-sl', '500', '-hold'] else: ARGS=[] def run(self): - args=self.ARGS - if with_xterm: - # (Debian) Transfert variable LD_LIBRARY_PATH aux shells fils (xterm) - env_ld_library_path=['env', 'LD_LIBRARY_PATH='+ os.getenv("LD_LIBRARY_PATH")] - args = args +['-T']+self.CMD[:1]+['-e'] + env_ld_library_path - args = args + self.CMD - #print "args = ", args - pid = os.spawnvp(os.P_NOWAIT, args[0], args) - process_id[pid]=self.CMD + global process_id + myargs=self.ARGS + if args['xterm']: + # (Debian) Transfert variable LD_LIBRARY_PATH aux shells fils (xterm) + env_ld_library_path=['env', 'LD_LIBRARY_PATH='+ os.getenv("LD_LIBRARY_PATH")] + myargs = myargs +['-T']+self.CMD[:1]+['-e'] + env_ld_library_path + command = myargs + self.CMD + #print "command = ", command + pid = os.spawnvp(os.P_NOWAIT, command[0], command) + process_id[pid]=self.CMD class CatalogServer(Server): SCMD1=['SALOME_ModuleCatalog_Server','-common'] SCMD2=['-personal','${HOME}/Salome/resources/CatalogModulePersonnel.xml'] - def setpath(self,liste_modules): + def setpath(self,modules_list): cata_path=[] - for module in liste_modules: + list_modules = modules_list[:] + list_modules.reverse() + for module in ["KERNEL"] + list_modules: module_root_dir=modules_root_dir[module] module_cata=module+"Catalog.xml" print " ", module_cata - cata_path.extend(glob.glob(os.path.join(module_root_dir,"share","salome","resources",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 class SalomeDSServer(Server): @@ -185,88 +145,73 @@ class RegistryServer(Server): CMD=['SALOME_Registry_Server', '--salome_session','theSession'] class ContainerCPPServer(Server): - CMD=['SALOME_Container','FactoryServer','-ORBInitRef','NameService=corbaname::localhost'] + #CMD=['SALOME_Container','FactoryServer','-ORBInitRef','NameService=corbaname::localhost'] + CMD=['SALOME_Container','FactoryServer'] class ContainerPYServer(Server): - CMD=['SALOME_ContainerPy.py','FactoryServerPy','-ORBInitRef','NameService=corbaname::localhost'] + #CMD=['SALOME_ContainerPy.py','FactoryServerPy','-ORBInitRef','NameService=corbaname::localhost'] + CMD=['SALOME_ContainerPy.py','FactoryServerPy'] class ContainerSUPERVServer(Server): - CMD=['SALOME_Container','SuperVisionContainer','-ORBInitRef','NameService=corbaname::localhost'] + #CMD=['SALOME_Container','SuperVisionContainer','-ORBInitRef','NameService=corbaname::localhost'] + CMD=['SALOME_Container','SuperVisionContainer'] class LoggerServer(Server): CMD=['SALOME_Logger_Server', 'logger.log'] class SessionLoader(Server): CMD=['SALOME_Session_Loader'] - if with_container_cpp: + if "cpp" in args['containers']: CMD=CMD+['CPP'] - if with_container_python: + if "python" in args['containers']: CMD=CMD+['PY'] - if with_container_superv: + if "superv" in args['containers']: CMD=CMD+['SUPERV'] - if with_gui: + if args['gui']: CMD=CMD+['GUI'] class SessionServer(Server): - CMD=['SALOME_Session_Server'] + 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[:] + list_modules.reverse() + for module in ["KERNEL"] + list_modules: + module_root_dir=modules_root_dir[module] + 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))) + 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): - CMD=['notifd','-c','${KERNEL_ROOT_DIR}/share/salome/resources/channel.cfg -DFactoryIORFileName=/tmp/${LOGNAME}_rdifact.ior -DChannelIORFileName=/tmp/${LOGNAME}_rdichan.ior'] - -# ----------------------------------------------------------------------------- -# -# Fonction de test -# - -def test(clt): - # create an LifeCycleCORBA instance - import LifeCycleCORBA - lcc = LifeCycleCORBA.LifeCycleCORBA(clt.orb) - med = lcc.FindOrLoadComponent("FactoryServer", "MED") - #pycalc = lcc.FindOrLoadComponent("FactoryServerPy", "CalculatorPy") - -# ----------------------------------------------------------------------------- -# -# Fonctions helper pour ajouter des variables d'environnement -# - -def add_path(directory): - os.environ["PATH"]=directory + ":" + os.environ["PATH"] - -def add_ld_library_path(directory): - os.environ["LD_LIBRARY_PATH"]=directory + ":" + os.environ["LD_LIBRARY_PATH"] - -def add_python_path(directory): - os.environ["PYTHONPATH"]=directory + ":" + os.environ["PYTHONPATH"] - sys.path[:0]=[directory] + myLogName = os.environ["LOGNAME"] + CMD=['notifd','-c',modules_root_dir["KERNEL"]+'/share/salome/resources/channel.cfg', '-DFactoryIORFileName=/tmp/'+myLogName+'_rdifact.ior', '-DChannelIORFileName=/tmp/'+myLogName+'_rdichan.ior'] # ----------------------------------------------------------------------------- # # initialisation des variables d'environnement # -python_version="python%d.%d" % sys.version_info[0:2] - -# -# Ajout du chemin d'acces aux executables de KERNEL dans le PATH -# - -add_path(os.path.join(kernel_root_dir,"bin","salome")) -#print "PATH=",os.environ["PATH"] - -# -# Ajout des modules dans le LD_LIBRARY_PATH -# -for module in liste_modules: - module_root_dir=modules_root_dir[module] - add_ld_library_path(os.path.join(module_root_dir,"lib","salome")) - os.environ["SALOME_trace"]="local" -if with_logger: +if args['logger']: os.environ["SALOME_trace"]="with_logger" locdir=os.environ['PWD'] libtracedir=os.path.join(locdir,"libSalomeTrace") - libtrace = os.path.join(kernel_root_dir,"lib","salome","libSALOMELoggerClient.so.0.0.0") + libtrace = os.path.join(modules_root_dir["KERNEL"],"lib",args['appname'],"libSALOMELoggerClient.so.0.0.0") libtraceln = os.path.join(libtracedir,"libSALOMELocalTrace.so") aCommand = 'rm -rf ' + libtracedir + "; " aCommand += 'mkdir ' + libtracedir + "; " @@ -274,27 +219,30 @@ if with_logger: aCommand += 'ln -s ' + libtrace + " " + libtraceln + ".0; " aCommand += 'ln -s ' + libtrace + " " + libtraceln + ".0.0.0; " os.system(aCommand) - add_ld_library_path(libtracedir) + add_path(libtracedir, "LD_LIBRARY_PATH") + +# set environment for SMESH plugins + +if "SMESH" in args["modules"]: + os.environ["SMESH_MeshersList"]="StdMeshers" + if not os.environ.has_key("SALOME_StdMeshersResources"): + os.environ["SALOME_StdMeshersResources"] = modules_root_dir["SMESH"]+"/share/"+args["appname"]+"/resources" + pass + if args.has_key("SMESH_plugins"): + for plugin in args["SMESH_plugins"]: + if os.environ.has_key(plugin.upper()+"_ROOT_DIR"): + os.environ["SMESH_MeshersList"]=os.environ["SMESH_MeshersList"]+":"+plugin + plugin_root = os.environ[plugin.upper()+"_ROOT_DIR"] + if not os.environ.has_key("SALOME_"+plugin+"Resources"): + os.environ["SALOME_"+plugin+"Resources"] = plugin_root+"/share/"+args["appname"]+"/resources" + add_path(os.path.join(plugin_root,"lib",python_version,"site-packages",args['appname']), "PYTHONPATH") + add_path(os.path.join(plugin_root,"lib",args['appname']), "PYTHONPATH") + add_path(os.path.join(plugin_root,"lib",args['appname']), "LD_LIBRARY_PATH") + add_path(os.path.join(plugin_root,"bin",args['appname']), "PYTHONPATH") + add_path(os.path.join(plugin_root,"bin",args['appname']), "PATH") + pass + pass -#print "LD_LIBRARY_PATH=",os.environ["LD_LIBRARY_PATH"] - -# -# Ajout des modules dans le PYTHONPATH (KERNEL prioritaire, donc en dernier) -# - -liste_modules_reverse=liste_modules[:] -liste_modules_reverse.reverse() -#print liste_modules -#print liste_modules_reverse -for module in liste_modules_reverse: - module_root_dir=modules_root_dir[module] - add_python_path(os.path.join(module_root_dir,"bin","salome")) - add_python_path(os.path.join(module_root_dir,"lib",python_version,"site-packages","salome")) - add_python_path(os.path.join(module_root_dir,"lib","salome")) - add_python_path(os.path.join(module_root_dir,"lib",python_version,"site-packages","salome","shared_modules")) - -#print "PYTHONPATH=",sys.path - import orbmodule # @@ -321,7 +269,7 @@ def startSalome(): # Lancement Session Loader # - if with_gui: + if args['gui']: SessionLoader().run() # @@ -333,125 +281,95 @@ def startSalome(): # (non obligatoire) Lancement Logger Server et attente de sa disponibilite dans le naming service # - if with_logger: + if args['logger']: LoggerServer().run() clt.waitLogger("Logger") - - # - # Lancement Registry Server + # Notify Server launch # - - RegistryServer().run() + NotifyServer().run() # - # Attente de la disponibilité du Registry dans le Naming Service + # Lancement Registry Server, attente de la disponibilité du Registry dans le Naming Service # - - clt.waitNS("/Registry") + if 'registry' not in args['embedded']: + RegistryServer().run() + clt.waitNS("/Registry") # - # Lancement Catalog Server + # Lancement Catalog Server, attente de la disponibilité du Catalog Server dans le Naming Service # - cataServer=CatalogServer() - cataServer.setpath(liste_modules) - cataServer.run() + if 'moduleCatalog' not in args['embedded']: + cataServer=CatalogServer() + cataServer.setpath(modules_list) + cataServer.run() + import SALOME_ModuleCatalog + clt.waitNS("/Kernel/ModulCatalog",SALOME_ModuleCatalog.ModuleCatalog) # - # Attente de la disponibilité du Catalog Server dans le Naming Service + # Lancement SalomeDS Server, attente de la disponibilité du SalomeDS dans le Naming Service # - import SALOME_ModuleCatalog - clt.waitNS("/Kernel/ModulCatalog",SALOME_ModuleCatalog.ModuleCatalog) - - # - # Lancement SalomeDS Server - # + 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") - os.environ["CSF_PluginDefaults"]=os.path.join(kernel_root_dir,"share","salome","resources") - os.environ["CSF_SALOMEDS_ResourcesDefaults"]=os.path.join(kernel_root_dir,"share","salome","resources") - SalomeDSServer().run() - - if "GEOM" in liste_modules: + if "GEOM" in modules_list: print "GEOM OCAF Resources" - os.environ["CSF_GEOMDS_ResourcesDefaults"]=os.path.join(modules_root_dir["GEOM"],"share","salome","resources") - - - # - # Attente de la disponibilité du SalomeDS dans le Naming Service - # + os.environ["CSF_GEOMDS_ResourcesDefaults"]=os.path.join(modules_root_dir["GEOM"],"share",args['appname'],"resources") - clt.waitNS("/myStudyManager") + if 'study' not in args['embedded']: + SalomeDSServer().run() + clt.waitNS("/myStudyManager") # # Lancement Session Server # - SessionServer().run() + mySessionServ=SessionServer() + mySessionServ.setpath(modules_list) + mySessionServ.run() # # Attente de la disponibilité du Session Server dans le Naming Service # - import SALOME - session=clt.waitNS("/Kernel/Session",SALOME.Session) + #import SALOME + #session=clt.waitNS("/Kernel/Session",SALOME.Session) if os.getenv("HOSTNAME") == None: if os.getenv("HOST") == None: os.environ["HOSTNAME"]="localhost" else: os.environ["HOSTNAME"]=os.getenv("HOST") - + theComputer = os.getenv("HOSTNAME") computerSplitName = theComputer.split('.') theComputer = computerSplitName[0] # - # Lancement Container C++ local + # Lancement Container C++ local, attente de la disponibilité du Container C++ local dans le Naming Service # - if with_container_cpp: - ContainerCPPServer().run() - - # - # Attente de la disponibilité du Container C++ local dans le Naming Service - # + 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 with_container_python: + 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 with_container_superv: - - # - # 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 @@ -463,42 +381,51 @@ def startSalome(): # ----------------------------------------------------------------------------- # +process_id = {} if __name__ == "__main__": - clt=None - try: - clt = startSalome() - except: - print - print - print "--- erreur au lancement Salome ---" - - #print process_id - - - filedict='/tmp/'+os.getenv('USER')+'_SALOME_pidict' - #filedict='/tmp/'+os.getlogin()+'_SALOME_pidict' - - fpid=open(filedict, 'w') - pickle.dump(process_id,fpid) - fpid.close() - - print - print "Sauvegarde du dictionnaire des process dans ", filedict - print "Pour tuer les process SALOME, executer : python killSalome.py depuis" - print "une console, ou bien killSalome() depuis le present interpreteur," - print "s'il n'est pas fermé." - print - print "runSalome, avec l'option --killall, commence par tuer les process restants d'une execution précédente." - print - print "Pour lancer uniquement le GUI, executer startGUI() depuis le present interpreteur," - print "s'il n'est pas fermé." - - # - # Impression arborescence Naming Service - # - - if clt != None: - print - print " --- registered objects tree in Naming Service ---" - clt.showNS() - + clt=None + try: + clt = startSalome() + except: + print + print + print "--- erreur au lancement Salome ---" + + #print process_id + + filedict='/tmp/'+os.getenv('USER')+"_"+str(args['port'])+'_'+args['appname'].upper()+'_pidict' + #filedict='/tmp/'+os.getlogin()+'_SALOME_pidict' + + + process_ids = [] + try: + fpid=open(filedict, 'r') + process_ids=pickle.load(fpid) + fpid.close() + except: + pass + + fpid=open(filedict, 'w') + process_ids.append(process_id) + pickle.dump(process_ids,fpid) + fpid.close() + + 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 + # + + if clt != None: + print + print " --- registered objects tree in Naming Service ---" + clt.showNS() diff --git a/bin/salome.launch b/bin/salome.launch new file mode 100644 index 000000000..920c968f6 --- /dev/null +++ b/bin/salome.launch @@ -0,0 +1,30 @@ + + + yes + no + no + yes + no + + + + + + + + + + + + + + registry + study + moduleCatalog + cppContainer + + + pyContainer + supervContainer + + diff --git a/bin/salome/runIDLparser.in b/bin/salome/runIDLparser.in new file mode 100644 index 000000000..085ac77d8 --- /dev/null +++ b/bin/salome/runIDLparser.in @@ -0,0 +1,45 @@ +#! /bin/bash + +# print the help message ==================================== + +# test $@="-h" -o -z $@ + +hh=0 + +if test "$#" = "0";then + hh=1 +else + for a in $@; do + if test "$a" = "-h"; then + hh=1 + fi + done +fi + +if test "$hh" = "1" ; then + echo "" + echo "Usage : " + echo "" + echo " to run IDLparser:" + echo "" + echo " $0 -Wbcatalog=[,icon=][,version=][,author=][,name=][,multistudy=][,remove=component_name] " + echo "" + echo " to have omniidl help:" + echo "" + echo " $0 -u " + echo "" + exit 1 +fi +#============================================================ + +# environment ============================================== +@ENVSCRIPT@ + +cd $DIR + +PYTHONPATH=${PYTHONPATH}:${SALOME_HOME_DIR}/bin +#============================================================ + +# omiidl ==================================================== +omniidl -bIDLparser -I ${SALOME_SRC_DIR}/idl $@ +#============================================================ diff --git a/bin/showNS.py b/bin/showNS.py new file mode 100755 index 000000000..2014aaeb0 --- /dev/null +++ b/bin/showNS.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python + +import orbmodule + +clt=orbmodule.client() + +clt.showNS()