]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
First implementation of the --wake-up-session option
authoradam <adam>
Thu, 24 Mar 2011 15:48:27 +0000 (15:48 +0000)
committeradam <adam>
Thu, 24 Mar 2011 15:48:27 +0000 (15:48 +0000)
bin/launchConfigureParser.py
bin/orbmodule.py
bin/runSalome.py

index cabc859a4ab6f76f00b384408fa3c100fbc747d2..fc3f11e324f8567a2779d43e6140be7985779c5a 100755 (executable)
@@ -62,6 +62,7 @@ gdb_session_nam = "gdb_session"
 ddd_session_nam = "ddd_session"
 valgrind_session_nam = "valgrind_session"
 shutdown_servers_nam = "shutdown_servers"
+wake_up_session_nam = "wake_up_session"
 
 # values in XML configuration file giving specific module parameters (<module_name> section)
 # which are stored in opts with key <module_name>_<parameter> (eg SMESH_plugins)
@@ -707,6 +708,15 @@ def CreateOptionParser (theAdditionalOptions=[]):
                                  dest="shutdown_servers",
                                  help=help_str)
 
+    # wake up session
+    help_str  = "Wake up a previously closed session. "
+    help_str += "The session object is found in the naming service pointed by the variable OMNIORB_CONFIG. "
+    help_str += "If this variable is not setted, the last configuration is taken. "
+    o_wake_up = optparse.Option("--wake-up-session",
+                                action="store_true",
+                                dest="wake_up_session", default=False,
+                                help=help_str)
+
     # All options
     opt_list = [o_t,o_g, # GUI/Terminal
                 o_d,o_o, # Desktop
@@ -733,6 +743,7 @@ def CreateOptionParser (theAdditionalOptions=[]):
                 o_ddd,
                 o_valgrind,
                 o_shutdown,
+                o_wake_up,
                 ]
 
     #std_options = ["gui", "desktop", "log_file", "py_scripts", "resources",
@@ -1029,6 +1040,10 @@ def get_env(theAdditionalOptions=[], appname="SalomeApp"):
         args[shutdown_servers_nam] = cmd_opts.shutdown_servers
         pass
 
+    # wake up session
+    if cmd_opts.wake_up_session is not None:
+        args[wake_up_session_nam] = cmd_opts.wake_up_session
+
     ####################################################
     # Add <theAdditionalOptions> values to args
     for add_opt in theAdditionalOptions:
index 21abd7b14315ee651fc628ac3ba709def9bdeaa9..95b6dd45919d636f30633f78487567202e18ec8f 100755 (executable)
@@ -61,7 +61,13 @@ class client:
           if verbose(): print "Launch Naming Service++",
           
       # On lance le Naming Server (doit etre dans le PATH)
-      NamingServer(args).run()
+      test = True
+      if args['wake_up_session']:
+         test = False
+         pass
+      if test:
+         NamingServer(args).run()
+         pass
       print "Searching Naming Service ",
       ncount=0
       delta=0.1
index ac2b60d5953fc21fdc2d8fe7ecf6e4653ce9bb08..e6d0a239c8b3d70686985ee140cc6e281db9c1b8 100755 (executable)
@@ -412,11 +412,51 @@ def startSalome(args, modules_list, modules_root_dir):
 
     if verbose(): print "startSalome ", args
     
+    #
+    # Wake up session option
+    #
+    if args['wake_up_session']:
+        if "OMNIORB_CONFIG" not in os.environ:
+            from salome_utils import generateFileName
+            home  = os.getenv("HOME")
+            appli = os.getenv("APPLI")
+            kwargs={}
+            if appli is not None: 
+                home = os.path.join(home, appli,"USERS")
+                kwargs["with_username"] = True
+                pass
+            last_running_config = generateFileName(home, prefix="omniORB",
+                                                   suffix="last",
+                                                   extension="cfg",
+                                                   hidden=True,
+                                                   **kwargs)
+            os.environ['OMNIORB_CONFIG'] = last_running_config
+            pass
+        pass
+    
     #
     # Initialisation ORB and Naming Service
     #
    
     clt=orbmodule.client(args)
+
+    #
+    # Wake up session option
+    #
+    if args['wake_up_session']:
+        import Engines
+        import SALOME
+        import SALOMEDS
+        import SALOME_ModuleCatalog
+        import SALOME_Session_idl
+        session = clt.waitNS("/Kernel/Session",SALOME.Session)
+        status = session.GetStatSession()
+        if status.activeGUI:
+            msg = "Session GUI is already active"
+            raise Exception(msg)
+        session.GetInterface()
+        return clt
+    
     # Save Naming service port name into
     # the file args["ns_port_log_file"]
     if args.has_key('ns_port_log_file'):
@@ -875,7 +915,15 @@ def main():
     save_config = True
     if args.has_key('save_config'):
         save_config = args['save_config']
-    searchFreePort(args, save_config)
+    # --
+    test = True
+    if args['wake_up_session']:
+        test = False
+        pass
+    if test:
+        searchFreePort(args, save_config)
+        pass
+    # --
     #setenv.main()
     setenv.set_env(args, modules_list, modules_root_dir)
     clt = useSalome(args, modules_list, modules_root_dir)