]> SALOME platform Git repositories - modules/yacs.git/commitdiff
Salome HOME
NRI : Update launch.
authornri <nri@opencascade.com>
Tue, 3 Jun 2003 11:29:43 +0000 (11:29 +0000)
committernri <nri@opencascade.com>
Tue, 3 Jun 2003 11:29:43 +0000 (11:29 +0000)
bin/runSalome
bin/runSalome.py
src/Loader/InquireServersQThread.cxx
src/Loader/InquireServersQThread.h
src/Loader/SALOME_Session_Loader.cxx

index 9a133bb9fecfc65a881338d3f53e73cefb952507..2734aa804f67b38c4d722d85b658b5c7d233410a 100755 (executable)
@@ -9,7 +9,10 @@ export SUPERV_ROOT_DIR=/Salome2/SUPERV_install
 export VISU_ROOT_DIR=/Salome2/VISU_install
 
 python killSalome.py
-python -i runSalome.py GEOM SMESH VISU SUPERV MED
+python -i runSalome.py --gui --modules=GEOM,SMESH,VISU,SUPERV,MED --xterm --containers=cpp,python
+#python -i runSalome.py --gui --modules=GEOM,SMESH,VISU,SUPERV,MED --logger --xterm
+#python -i runSalome.py --modules=GEOM,SMESH,VISU,SUPERV,MED
+#python -i runSalome.py --help
 
 # -----------------------------------------------------------------------------
 #
index 0a6514bde3759f8ed7b0a2843d50e7bc448793c9..c61998d896dd61c79d92a7744cee68277ec1d658 100755 (executable)
@@ -1,18 +1,74 @@
 #!/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)
 
 # -----------------------------------------------------------------------------
 #
@@ -44,6 +100,8 @@ liste_modules[:0]=["KERNEL"]
 #print liste_modules
 #print modules_root_dir
 
+if "SUPERV" in liste_modules:with_container_superv=1
+
 import orbmodule
 
 # -----------------------------------------------------------------------------
@@ -53,8 +111,11 @@ 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
@@ -92,6 +153,17 @@ class ContainerSUPERVServer(Server):
 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']
 
@@ -181,6 +253,13 @@ for module in liste_modules_reverse:
 #
    
 def startSalome():
+
+  #
+  # Lancement Session Loader
+  #
+
+  SessionLoader().run()
+
   #
   # Initialisation ORB et Naming Service
   #
@@ -190,8 +269,10 @@ def startSalome():
   # (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
@@ -255,33 +336,33 @@ def startSalome():
   #
   # 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
@@ -295,11 +376,12 @@ def startSalome():
 
        clt.waitNS("/Containers/" + theComputer + "/SuperVisionContainer")
 
+
   #
   # Activation du GUI de Session Server
   #
-
-  session.GetInterface()
+       
+  #session.GetInterface()
 
   end_time = os.times()
   print
index 1102aa39a957287a199858ebd4579fee37e531ca..39a7580d5ed5394dbc787c5a8f09fa66d36ff071 100644 (file)
@@ -53,6 +53,7 @@ static QString addSlash( const QString& path );
 InquireServersGUI::InquireServersGUI()
      : QVBox(0, "SFA splash", Qt::WDestructiveClose | Qt::WStyle_Customize | Qt::WStyle_NoBorder )
 {
+  myGUI = false;
   myThread = new InquireServersQThread(this);
 
   // 1. Polish the appearance
@@ -140,6 +141,7 @@ void InquireServersGUI::ClickOnCancel()
 {
   //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);
@@ -200,7 +202,7 @@ InquireServersQThread::InquireServersQThread( InquireServersGUI* r )
   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" );
@@ -224,13 +226,22 @@ InquireServersQThread::InquireServersQThread( InquireServersGUI* r )
   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);
+    }
   }
 }
 
@@ -238,9 +249,18 @@ void InquireServersQThread::run()
 {
 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);
@@ -249,7 +269,7 @@ while (IsChecking)
        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
index b67983b760284f4107aabc0fcd77f0e314736f1b..1a1a74c1eabc2d9d70631c4b0dc190afcb364aaf 100644 (file)
@@ -94,6 +94,9 @@ public:
   void getArgs(  int& _argc, char *** _argv);
   //return exit status: 0 - OK, >0 - BAD (some servers doesn't exists or user click cancel button) 
   int getExitStatus();
+  //launch IAPP
+  bool withGUI() { return myGUI; }
+  void withGUI(bool gui) { myGUI = gui; }
 
 protected:
   virtual void customEvent( QCustomEvent* ); 
@@ -104,6 +107,7 @@ private:
   QProgressBar* myPrgBar;
   //this string contains description of currently asked server
   QLabel* myLabel;
+  bool myGUI;
 
 private slots:
 
index 3e529784c68edcbf10efbc353c1b8ecf7176d654..e5a6c219d5c23f86293dddb2c99267699afe82ef 100644 (file)
@@ -40,6 +40,51 @@ int main(int argc, char **argv)
   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 ;
 }