#!/usr/bin/env python
-usage="""USAGE: runSalome.py module1 module2 ...
- où modulen est le nom d'un module Salome à charger dans le catalogue
+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
+
La variable d'environnement <modulen>_ROOT_DIR doit etre préalablement
positionnée (modulen doit etre en majuscule).
KERNEL_ROOT_DIR est obligatoire.
"""
-import sys,os,string,glob,time,signal,pickle
+def message(code, msg=''):
+ if msg: print msg
+ sys.exit(code)
+
+import sys,os,string,glob,time,signal,pickle,getopt
init_time=os.times()
-liste_modules=sys.argv[1:]
+opts, args=getopt.getopt(sys.argv[1:], 'hmglxc:', ['help','modules=','gui','logger','xterm','containers='])
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
+
+except getopt.error, msg:
+ print usage
+ sys.exit(1)
# -----------------------------------------------------------------------------
#
#print liste_modules
#print modules_root_dir
+if "SUPERV" in liste_modules:with_container_superv=1
+
import orbmodule
# -----------------------------------------------------------------------------
class Server:
CMD=[]
- ARGS=['xterm', '-iconic', '-sb', '-sl', '500', '-e']
- #ARGS=[]
+ if with_xterm:
+ ARGS=['xterm', '-iconic', '-sb', '-sl', '500', '-e']
+ else:
+ ARGS=[]
+
def run(self):
args = self.ARGS+self.CMD
#print "args = ", args
class LoggerServer(Server):
CMD=['SALOME_Logger_Server', 'logger.log']
+class SessionLoader(Server):
+ CMD=['SALOME_Session_Loader']
+ if with_container_cpp:
+ CMD=CMD+['CPP']
+ if with_container_python:
+ CMD=CMD+['PY']
+ if with_container_superv:
+ CMD=CMD+['SUPERV']
+ if with_gui:
+ CMD=CMD+['GUI']
+
class SessionServer(Server):
CMD=['SALOME_Session_Server']
#
def startSalome():
+
+ #
+ # Lancement Session Loader
+ #
+
+ SessionLoader().run()
+
#
# Initialisation ORB et Naming Service
#
# (non obligatoire) Lancement Logger Server et attente de sa disponibilite dans le naming service
#
- #LoggerServer().run()
- #clt.waitLogger("Logger")
+ if with_logger:
+ LoggerServer().run()
+ clt.waitLogger("Logger")
+
#
# Lancement Registry Server
#
# Lancement Container C++ local
#
+ if with_container_cpp:
+ ContainerCPPServer().run()
- ContainerCPPServer().run()
-
- #
- # Attente de la disponibilité du Container C++ local dans le Naming Service
- #
+ #
+ # Attente de la disponibilité du Container C++ local dans le Naming Service
+ #
- theComputer = os.getenv("HOSTNAME")
- computerSplitName = theComputer.split('.')
- theComputer = computerSplitName[0]
+ theComputer = os.getenv("HOSTNAME")
+ computerSplitName = theComputer.split('.')
+ theComputer = computerSplitName[0]
- clt.waitNS("/Containers/" + theComputer + "/FactoryServer")
+ clt.waitNS("/Containers/" + theComputer + "/FactoryServer")
#
# Lancement Container Python local
#
- ContainerPYServer().run()
-
- #
- # Attente de la disponibilité du Container Python local dans le Naming Service
- #
+ if with_container_python:
+ ContainerPYServer().run()
- clt.waitNS("/Containers/" + theComputer + "/FactoryServerPy")
+ #
+ # Attente de la disponibilité du Container Python local dans le Naming Service
+ #
+
+ clt.waitNS("/Containers/" + theComputer + "/FactoryServerPy")
-
- if "SUPERV" in liste_modules:
+ if with_container_superv:
#
# Lancement Container Supervision local
clt.waitNS("/Containers/" + theComputer + "/SuperVisionContainer")
+
#
# Activation du GUI de Session Server
#
-
- session.GetInterface()
+
+ #session.GetInterface()
end_time = os.times()
print
InquireServersGUI::InquireServersGUI()
: QVBox(0, "SFA splash", Qt::WDestructiveClose | Qt::WStyle_Customize | Qt::WStyle_NoBorder )
{
+ myGUI = false;
myThread = new InquireServersQThread(this);
// 1. Polish the appearance
{
//it's necessary to stop asking servers
myThread->stop();
+ myGUI = false;
//Also we should send QCloseEvent in order to close this widget (and remove from screen)
//QThread::postEvent ( this, new QCloseEvent() );
qApp->exit(1);
char* cenv;
IsChecking = true;
- myServersCount = 8;
+ myServersCount = 5;
//how many times we should repeat attempts to get response from all needed for launching SALOME servers
myRepeat = 30; // default value, user can change it by setting CSF_RepeatServerRequest env.variable
cenv = getenv( "CSF_RepeatServerRequest" );
r->getArgs( _argc, &_argv);
// NRI : Temporary solution for SuperVisionContainer
- for ( int i=1; i<=_argc; i++) {
- if (strcmp(_argv[i],"CPP")==0)
+ for ( int i=1; i<=(_argc-1); i++) {
+ if (strcmp(_argv[i],"CPP")==0) {
myMessages[5] = str + "SALOME_Container FactoryServer" + "...";
- if (strcmp(_argv[i],"PYTHON")==0)
+ myServersCount++;
+ }
+ if (strcmp(_argv[i],"PYTHON")==0) {
myMessages[6] = str + "SALOME_ContainerPy.py FactoryServerPy" + "...";
- if (strcmp(_argv[i],"SUPERV")==0)
+ myServersCount++;
+ }
+ if (strcmp(_argv[i],"SUPERV")==0) {
myMessages[7] = str + "SALOME_Container SuperVisionContainer" + "...";
+ myServersCount++;
+ }
+ if (strcmp(_argv[i],"GUI")==0) {
+ r->withGUI(true);
+ }
}
}
{
while (IsChecking)
{
- for (int i=1; i<=myServersCount; i++)
+ for (int i=1; i<=8; i++)
{
- if ( myMessages[i-1].isEmpty() ) continue;
+ if ( myMessages[i-1].isEmpty() ) {
+ if (i==8) {
+ IsChecking = false;
+ //myExitStatus should be 0 because all servers exist and work
+ myExitStatus = 0;
+ //we should send QCloseEvent in order to close this widget (and remove from screen)
+ QThread::postEvent ( receiver , new QCloseEvent() );
+ } else
+ continue;
+ }
QString *message = new QString(myMessages[i-1]);
QThread::postEvent( receiver, new InquireEvent( ( QEvent::Type )InquireEvent::ProgressEventLabel, message ) );
QThread::usleep(200000);
if (result)
{
QThread::postEvent( receiver, new InquireEvent( ( QEvent::Type )InquireEvent::ProgressEvent, new int( i ) ) );
- if (i==myServersCount)
+ if (i==8)
{
IsChecking = false;
//myExitStatus should be 0 because all servers exist and work
if (myIS.getExitStatus())
exit(1);
//VRVcd: T2.4 - Trace management improvement
+ if (myIS.withGUI()) {
+ try
+ {
+ CORBA::ORB_ptr orb = CORBA::ORB_init(argc,argv) ;
+
+ SALOME_NamingService &NS = *SINGLETON_<SALOME_NamingService>::Instance() ;
+ ASSERT(SINGLETON_<SALOME_NamingService>::IsAlreadyExisting()) ;
+ NS.init_orb( orb ) ;
+
+ CORBA::Object_var obj = NS.Resolve("/Kernel/Session");
+
+ SALOME::Session_var session = SALOME::Session::_narrow(obj) ;
+ ASSERT(! CORBA::is_nil(session));
+ MESSAGE("SALOME::Session::_narrow(obj)");
+ INFOS("Corba initialisation, Distant server");
+
+ // -------------------------------------------------------------
+
+ session->GetInterface() ;
+
+ // -------------------------------------------------------------
+
+ orb->destroy() ;
+ }
+ catch (ServiceUnreachable&)
+ {
+ INFOS("Caught exception: Naming Service Unreachable");
+ }
+ catch (CORBA::COMM_FAILURE&)
+ {
+ INFOS("Caught CORBA::SystemException CommFailure.");
+ }
+ catch (CORBA::SystemException&)
+ {
+ INFOS("Caught CORBA::SystemException.");
+ }
+ catch (CORBA::Exception&)
+ {
+ INFOS("Caught CORBA::Exception.");
+ }
+ catch (...)
+ {
+ INFOS("Caught unknown exception.");
+ }
+ }
return 0 ;
}