]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Implement the --shutdown-servers command line option with 0 as default
authoradam <adam>
Tue, 29 Sep 2009 09:29:13 +0000 (09:29 +0000)
committeradam <adam>
Tue, 29 Sep 2009 09:29:13 +0000 (09:29 +0000)
bin/launchConfigureParser.py
bin/runSalome.py

index 004ac6b7a5916b4090c2d028800147d1935a6727..bcce12005d94320edba1be7007955c445f0531b7 100755 (executable)
@@ -57,6 +57,7 @@ test_nam       = "test"
 play_nam       = "play"
 gdb_session_nam = "gdb_session"
 ddd_session_nam = "ddd_session"
+shutdown_servers_nam = "shutdown_servers"
 
 # 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)
@@ -74,7 +75,7 @@ standalone_choices = [ "registry", "study", "moduleCatalog", "cppContainer", "py
 
 # values of boolean type (must be '0' or '1').
 # xml_parser.boolValue() is used for correct setting
-boolKeys = ( gui_nam, splash_nam, logger_nam, file_nam, xterm_nam, portkill_nam, killall_nam, except_nam, pinter_nam )
+boolKeys = ( gui_nam, splash_nam, logger_nam, file_nam, xterm_nam, portkill_nam, killall_nam, except_nam, pinter_nam, shutdown_servers_nam )
 intKeys = ( interp_nam, )
 
 # values of list type
@@ -635,6 +636,19 @@ def CreateOptionParser (theAdditionalOptions=[]):
                             dest="ddd_session", default=False,
                             help=help_str)
     
+    # shutdown-servers. Default: False.
+    help_str  = "1 to shutdown standalone servers when leaving python interpreter, "
+    help_str += "0 to keep the standalone servers as daemon [default]. "
+    help_str += "This option is only useful in batchmode "
+    help_str += "(terminal mode or without showing desktop)."
+    o_shutdown = optparse.Option("--shutdown-servers",
+                                 metavar="<1/0>",
+                                 #type="choice", choices=boolean_choices,
+                                 type="string",
+                                 action="callback", callback=store_boolean, callback_args=('shutdown_servers',),
+                                 dest="shutdown_servers",
+                                 help=help_str)
+    
     # All options
     opt_list = [o_t,o_g, # GUI/Terminal
                 o_d,o_o, # Desktop
@@ -659,6 +673,7 @@ def CreateOptionParser (theAdditionalOptions=[]):
                 o_play,  # Reproducing test script with help of TestRecorder
                 o_gdb,
                 o_ddd,
+                o_shutdown,
                 ]
 
     #std_options = ["gui", "desktop", "log_file", "py_scripts", "resources",
@@ -952,6 +967,13 @@ def get_env(theAdditionalOptions=[], appname="SalomeApp"):
     if cmd_opts.ddd_session is not None:
         args[ddd_session_nam] = cmd_opts.ddd_session
 
+    # Shutdown servers
+    if cmd_opts.shutdown_servers is None:
+        args[shutdown_servers_nam] = 0
+    else:
+        args[shutdown_servers_nam] = cmd_opts.shutdown_servers
+        pass
+        
     ####################################################
     # Add <theAdditionalOptions> values to args
     for add_opt in theAdditionalOptions:
index 0713403623ac0436b9f7e72d8ace1d223e799c85..ce89f82697bdc37771fd5109f20e25185e725fd9 100755 (executable)
@@ -656,6 +656,22 @@ def useSalome(args, modules_list, modules_root_dir):
             clt.showNS()
             pass
         
+        if not args['gui'] or not args['session_gui']:
+            if args['shutdown_servers']:
+                class __utils__(object):
+                    def __init__(self, port):
+                        self.port = port
+                        import killSalomeWithPort
+                        self.killSalomeWithPort = killSalomeWithPort
+                        return
+                    def __del__(self):
+                        self.killSalomeWithPort.killMyPort(self.port)
+                        return
+                    pass
+                args['shutdown_servers'] = __utils__(args['port'])
+                pass
+            pass
+        
         # run python scripts, passed via --execute option
         toimport = []
         if args.has_key('pyscript'):