X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=bin%2FrunSalome.py;h=722629ad4694265738e3dee09443f937a813f01c;hb=7abfafb698042a8635b7cbf9d2347937f2036ba8;hp=6e7b0938edc00fede9a2d0a4d04559978ae9beab;hpb=a66b03a69e4472ccdffa9ce5531072c84727d6ce;p=modules%2Fkernel.git diff --git a/bin/runSalome.py b/bin/runSalome.py index 6e7b0938e..722629ad4 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -1,11 +1,30 @@ #!/usr/bin/env python +# Copyright (C) 2005 OPEN CASCADE, CEA, EDF R&D, LEG +# PRINCIPIA R&D, EADS CCR, Lip6, BV, CEDRAT +# 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. +# +# This library is distributed in the hope that it will be useful +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + import sys, os, string, glob, time, pickle import orbmodule process_id = {} -# salome_subdir variable is used for composing paths like $KERNEL_ROOT_DIR/share/salome/resources, etc. +# salome_subdir variable is used for composing paths like $KERNEL_ROOT_DIR/share/salome/resources/kernel, etc. # before moving to SUIT-based gui, instead of salome_subdir there was args['appname'] used. # but after - 'appname' = "SalomeApp", so using it in making the subdirectory is an error. salome_subdir = "salome" @@ -56,8 +75,9 @@ def get_config(): modules_list = [] if args.has_key("modules"): modules_list += args["modules"] - # KERNEL must be last in the list to locate it at the first place in PATH - modules_list[:0] = ["GUI"] + # KERNEL must be last in the list to locate it at the first place in PATH + if args["gui"] : + modules_list[:0] = ["GUI"] modules_list[:0] = ["KERNEL"] modules_list.reverse() @@ -65,7 +85,7 @@ def get_config(): to_remove_list=[] for module in modules_list : - module_variable=module.upper()+"_ROOT_DIR" + module_variable=module+"_ROOT_DIR" if not os.environ.has_key(module_variable): print "*******************************************************" print "*" @@ -103,29 +123,37 @@ def set_env(args, modules_list, modules_root_dir): python_version="python%d.%d" % sys.version_info[0:2] modules_root_dir_list = [] - modules_list = modules_list[:] + ["GUI"] + if args["gui"] : + modules_list = modules_list[:] + ["GUI"] modules_list = modules_list[:] + ["KERNEL"] for module in modules_list : - module_root_dir = modules_root_dir[module] - modules_root_dir_list[:0] = [module_root_dir] - add_path(os.path.join(module_root_dir,"lib",salome_subdir), - "LD_LIBRARY_PATH") - add_path(os.path.join(module_root_dir,"bin",salome_subdir), - "PATH") - if os.path.exists(module_root_dir + "/examples") : - add_path(os.path.join(module_root_dir,"examples"), + if modules_root_dir.has_key(module): + module_root_dir = modules_root_dir[module] + modules_root_dir_list[:0] = [module_root_dir] + add_path(os.path.join(module_root_dir,"lib",salome_subdir), + "LD_LIBRARY_PATH") + add_path(os.path.join(module_root_dir,"bin",salome_subdir), + "PATH") + if os.path.exists(module_root_dir + "/examples") : + add_path(os.path.join(module_root_dir,"examples"), + "PYTHONPATH") + pass + add_path(os.path.join(module_root_dir,"bin",salome_subdir), + "PYTHONPATH") + add_path(os.path.join(module_root_dir,"lib", + python_version,"site-packages", + salome_subdir), + "PYTHONPATH") + add_path(os.path.join(module_root_dir,"lib",salome_subdir), "PYTHONPATH") - add_path(os.path.join(module_root_dir,"bin",salome_subdir), - "PYTHONPATH") - add_path(os.path.join(module_root_dir,"lib", - python_version,"site-packages",salome_subdir), - "PYTHONPATH") - add_path(os.path.join(module_root_dir,"lib",salome_subdir), - "PYTHONPATH") - add_path(os.path.join(module_root_dir,"lib", - python_version,"site-packages",salome_subdir, - "shared_modules"), - "PYTHONPATH") + add_path(os.path.join(module_root_dir,"lib", + python_version,"site-packages", + salome_subdir, + "shared_modules"), + "PYTHONPATH") + pass + pass + os.environ["SALOMEPATH"]=":".join(modules_root_dir_list) @@ -144,17 +172,25 @@ def set_env(args, modules_list, modules_root_dir): 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" + = modules_root_dir["SMESH"]+"/share/"+args["appname"]+"/resources/smesh" pass if args.has_key("SMESH_plugins"): for plugin in args["SMESH_plugins"]: - if os.environ.has_key(plugin.upper()+"_ROOT_DIR"): + plugin_root = "" + if os.environ.has_key(plugin+"_ROOT_DIR"): + plugin_root = os.environ[plugin+"_ROOT_DIR"] + else: + # workaround to avoid modifications of existing environment + if os.environ.has_key(plugin.upper()+"_ROOT_DIR"): + plugin_root = os.environ[plugin.upper()+"_ROOT_DIR"] + pass + pass + if plugin_root != "": 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" + = plugin_root+"/share/"+args["appname"]+"/resources/"+plugin.lower() add_path(os.path.join(plugin_root,"lib",python_version, "site-packages",salome_subdir), "PYTHONPATH") @@ -172,27 +208,29 @@ def set_env(args, modules_list, modules_root_dir): # set environment for SUPERV module os.environ["ENABLE_MACRO_NODE"]="1" # set resources variables if not yet set - if os.getenv("GUI_ROOT_DIR"): - if not os.getenv("SUITRoot"): os.environ["SUITRoot"] = os.getenv("GUI_ROOT_DIR") + "/share/salome" - if not os.getenv("SalomeAppConfig"): os.environ["SalomeAppConfig"] = os.getenv("GUI_ROOT_DIR") + "/share/salome/resources" - pass - - os.environ["CSF_PluginDefaults"] \ - = os.path.join(modules_root_dir["KERNEL"],"share", - salome_subdir,"resources") + # Done now by launchConfigureParser.py + #if os.getenv("GUI_ROOT_DIR"): + #if not os.getenv("SalomeAppConfig"): os.environ["SalomeAppConfig"] = os.getenv("GUI_ROOT_DIR") + "/share/salome/resources/gui" + + # set CSF_PluginDefaults variable only if it is not customized + # by the user + if not os.getenv("CSF_PluginDefaults"): + os.environ["CSF_PluginDefaults"] \ + = os.path.join(modules_root_dir["KERNEL"],"share", + salome_subdir,"resources","kernel") os.environ["CSF_SALOMEDS_ResourcesDefaults"] \ = os.path.join(modules_root_dir["KERNEL"],"share", - salome_subdir,"resources") + salome_subdir,"resources","kernel") if "GEOM" in modules_list: print "GEOM OCAF Resources" os.environ["CSF_GEOMDS_ResourcesDefaults"] \ = os.path.join(modules_root_dir["GEOM"],"share", - salome_subdir,"resources") + salome_subdir,"resources","geom") print "GEOM Shape Healing Resources" os.environ["CSF_ShHealingDefaults"] \ = os.path.join(modules_root_dir["GEOM"],"share", - salome_subdir,"resources") + salome_subdir,"resources","geom") # ----------------------------------------------------------------------------- @@ -249,6 +287,7 @@ class Server: """Generic class for CORBA server launch""" def initArgs(self): + self.PID=None self.CMD=[] self.ARGS=[] if self.args['xterm']: @@ -271,6 +310,7 @@ class Server: print "command = ", command pid = os.spawnvp(os.P_NOWAIT, command[0], command) process_id[pid]=self.CMD + self.PID = pid class InterpServer(Server): @@ -286,6 +326,7 @@ class InterpServer(Server): #print "command = ", command pid = os.spawnvp(os.P_NOWAIT, command[0], command) process_id[pid]=self.CMD + self.PID = pid # --- @@ -303,14 +344,32 @@ class CatalogServer(Server): cata_path=[] list_modules = modules_list[:] list_modules.reverse() - for module in ["KERNEL", "GUI"] + 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_subdir, - "resources",module_cata))) + if self.args["gui"] : + list_modules = ["KERNEL", "GUI"] + list_modules + else : + list_modules = ["KERNEL"] + list_modules + for module in list_modules: + if modules_root_dir.has_key(module): + module_root_dir=modules_root_dir[module] + module_cata=module+"Catalog.xml" + #print " ", module_cata + if os.path.exists(os.path.join(module_root_dir, + "share",salome_subdir, + "resources",module.lower(), + module_cata)): + cata_path.extend( + glob.glob(os.path.join(module_root_dir, + "share",salome_subdir, + "resources",module.lower(), + module_cata))) + else: + cata_path.extend( + glob.glob(os.path.join(module_root_dir, + "share",salome_subdir, + "resources", + module_cata))) + pass + pass self.CMD=self.SCMD1 + [string.join(cata_path,':')] + self.SCMD2 # --- @@ -365,7 +424,10 @@ class LoggerServer(Server): class SessionServer(Server): def __init__(self,args): - self.args=args + self.args = args.copy() + # Bug 11512 (Problems with runSalome --xterm on Mandrake and Debian Sarge) + self.args['xterm']=0 + # self.initArgs() self.SCMD1=['SALOME_Session_Server'] self.SCMD2=[] @@ -393,22 +455,43 @@ class SessionServer(Server): self.SCMD2+=['SUPERV'] if self.args['gui']: self.SCMD2+=['GUI'] - if self.args['splash']: + if self.args['splash'] and self.args['gui']: self.SCMD2+=['SPLASH'] + if self.args['noexcepthandler']: + self.SCMD2+=['noexcepthandler'] + if self.args.has_key('modules'): + self.SCMD2+=['--modules ('] + for mod in self.args['modules']: + self.SCMD2+=[mod + ':'] + self.SCMD2+=[')'] def setpath(self,modules_list,modules_root_dir): cata_path=[] list_modules = modules_list[:] list_modules.reverse() - for module in ["KERNEL", "GUI"] + list_modules: + if self.args["gui"] : + list_modules = ["KERNEL", "GUI"] + list_modules + else : + list_modules = ["KERNEL"] + list_modules + for module in 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_subdir,"resources", - module_cata))) - if 'moduleCatalog' in self.args['embedded']: + if os.path.exists(os.path.join(module_root_dir, + "share",salome_subdir, + "resources",module.lower(), + module_cata)): + cata_path.extend( + glob.glob(os.path.join(module_root_dir,"share", + salome_subdir,"resources", + module.lower(),module_cata))) + else: + cata_path.extend( + glob.glob(os.path.join(module_root_dir,"share", + salome_subdir,"resources", + module_cata))) + pass + if (self.args["gui"]) & ('moduleCatalog' in self.args['embedded']): self.CMD=self.SCMD1 + [string.join(cata_path,':')] + self.SCMD2 else: self.CMD=self.SCMD1 + self.SCMD2 @@ -421,31 +504,46 @@ class ContainerManagerServer(Server): self.initArgs() self.SCMD1=['SALOME_ContainerManagerServer'] self.SCMD2=[] - if 'registry' in self.args['embedded']: - self.SCMD1+=['--with','Registry', - '(','--salome_session','theSession',')'] - if 'moduleCatalog' in self.args['embedded']: - self.SCMD1+=['--with','ModuleCatalog','(','-common'] - self.SCMD2+=['-personal', - '${HOME}/Salome/resources/CatalogModulePersonnel.xml',')'] - if 'study' in self.args['embedded']: - self.SCMD2+=['--with','SALOMEDS','(',')'] - if 'cppContainer' in self.args['embedded']: - self.SCMD2+=['--with','Container','(','FactoryServer',')'] + if args["gui"] : + if 'registry' in self.args['embedded']: + self.SCMD1+=['--with','Registry', + '(','--salome_session','theSession',')'] + if 'moduleCatalog' in self.args['embedded']: + self.SCMD1+=['--with','ModuleCatalog','(','-common'] + self.SCMD2+=['-personal', + '${HOME}/Salome/resources/CatalogModulePersonnel.xml',')'] + if 'study' in self.args['embedded']: + self.SCMD2+=['--with','SALOMEDS','(',')'] + if 'cppContainer' in self.args['embedded']: + self.SCMD2+=['--with','Container','(','FactoryServer',')'] def setpath(self,modules_list,modules_root_dir): cata_path=[] list_modules = modules_list[:] list_modules.reverse() - for module in ["KERNEL", "GUI"] + 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", - self.args['appname'],"resources", - module_cata))) - if 'moduleCatalog' in self.args['embedded']: + if self.args["gui"] : + list_modules = ["GUI"] + list_modules + for module in ["KERNEL"] + list_modules: + if modules_root_dir.has_key(module): + module_root_dir=modules_root_dir[module] + module_cata=module+"Catalog.xml" + #print " ", module_cata + if os.path.exists(os.path.join(module_root_dir, + "share",salome_subdir, + "resources",module.lower(), + module_cata)): + cata_path.extend( + glob.glob(os.path.join(module_root_dir,"share", + self.args['appname'],"resources", + module.lower(),module_cata))) + else: + cata_path.extend( + glob.glob(os.path.join(module_root_dir,"share", + self.args['appname'],"resources", + module_cata))) + pass + pass + if (self.args["gui"]) & ('moduleCatalog' in self.args['embedded']): self.CMD=self.SCMD1 + [string.join(cata_path,':')] + self.SCMD2 else: self.CMD=self.SCMD1 + self.SCMD2 @@ -457,7 +555,7 @@ class NotifyServer(Server): self.modules_root_dir=modules_root_dir myLogName = os.environ["LOGNAME"] self.CMD=['notifd','-c', - self.modules_root_dir["KERNEL"] +'/share/salome/resources/channel.cfg', + 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', @@ -469,7 +567,13 @@ class NotifyServer(Server): def startGUI(): """Salome Session Graphic User Interface activation""" + import Engines import SALOME + import SALOMEDS + import SALOME_ModuleCatalog + reload(Engines) + reload(SALOME) + reload(SALOMEDS) import SALOME_Session_idl session=clt.waitNS("/Kernel/Session",SALOME.Session) session.GetInterface() @@ -505,15 +609,23 @@ def startSalome(args, modules_list, modules_root_dir): myServer=NotifyServer(args,modules_root_dir) myServer.run() + # Lancement Session Server (to show splash ASAP) + # + + if args["gui"]: + mySessionServ = SessionServer(args) + mySessionServ.setpath(modules_list,modules_root_dir) + mySessionServ.run() + # # Lancement Registry Server, # attente de la disponibilite du Registry dans le Naming Service # - if 'registry' not in args['embedded']: + if ('registry' not in args['embedded']) | (args["gui"] == 0) : myServer=RegistryServer(args) myServer.run() - clt.waitNS("/Registry") + clt.waitNSPID("/Registry",myServer.PID) # # Lancement Catalog Server, @@ -521,12 +633,12 @@ def startSalome(args, modules_list, modules_root_dir): # - if 'moduleCatalog' not in args['embedded']: + if ('moduleCatalog' not in args['embedded']) | (args["gui"] == 0): cataServer=CatalogServer(args) cataServer.setpath(modules_list,modules_root_dir) cataServer.run() import SALOME_ModuleCatalog - clt.waitNS("/Kernel/ModulCatalog",SALOME_ModuleCatalog.ModuleCatalog) + clt.waitNSPID("/Kernel/ModulCatalog",cataServer.PID,SALOME_ModuleCatalog.ModuleCatalog) # # Lancement SalomeDS Server, @@ -534,11 +646,11 @@ def startSalome(args, modules_list, modules_root_dir): # #print "ARGS = ",args - if 'study' not in args['embedded']: + if ('study' not in args['embedded']) | (args["gui"] == 0): print "RunStudy" myServer=SalomeDSServer(args) myServer.run() - clt.waitNS("/myStudyManager") + clt.waitNSPID("/myStudyManager",myServer.PID) # # Lancement ContainerManagerServer @@ -567,7 +679,7 @@ def startSalome(args, modules_list, modules_root_dir): if 'cppContainer' in args['standalone']: myServer=ContainerCPPServer(args) myServer.run() - clt.waitNS("/Containers/" + theComputer + "/FactoryServer") + clt.waitNSPID("/Containers/" + theComputer + "/FactoryServer",myServer.PID) # # Lancement Container Python local, @@ -578,7 +690,7 @@ def startSalome(args, modules_list, modules_root_dir): if 'pyContainer' in args['standalone']: myServer=ContainerPYServer(args) myServer.run() - clt.waitNS("/Containers/" + theComputer + "/FactoryServerPy") + clt.waitNSPID("/Containers/" + theComputer + "/FactoryServerPy",myServer.PID) # # Lancement Container Supervision local, @@ -589,22 +701,23 @@ def startSalome(args, modules_list, modules_root_dir): if 'supervContainer' in args['standalone']: myServer=ContainerSUPERVServer(args) myServer.run() - clt.waitNS("/Containers/" + theComputer + "/SuperVisionContainer") + clt.waitNSPID("/Containers/" + theComputer + "/SuperVisionContainer",myServer.PID) # - # Lancement Session Server - # - mySessionServ = SessionServer(args) - mySessionServ.setpath(modules_list,modules_root_dir) - mySessionServ.run() -##---------------- - # Attente de la disponibilite du Session Server dans le Naming Service # - - import SALOME - import SALOME_Session_idl - session=clt.waitNS("/Kernel/Session",SALOME.Session) + + if args["gui"]: +##---------------- + import Engines + import SALOME + import SALOMEDS + import SALOME_ModuleCatalog + reload(Engines) + reload(SALOME) + reload(SALOMEDS) + import SALOME_Session_idl + session=clt.waitNSPID("/Kernel/Session",mySessionServ.PID,SALOME.Session) end_time = os.times() print