From: adam Date: Tue, 29 Sep 2009 09:29:13 +0000 (+0000) Subject: Implement the --shutdown-servers command line option with 0 as default X-Git-Tag: V5_1_3rc1~24 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=03b27bb3323e9cfeb8761be2306a2a57d945a7f5;p=modules%2Fkernel.git Implement the --shutdown-servers command line option with 0 as default --- diff --git a/bin/launchConfigureParser.py b/bin/launchConfigureParser.py index 004ac6b7a..bcce12005 100755 --- a/bin/launchConfigureParser.py +++ b/bin/launchConfigureParser.py @@ -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 ( section) # which are stored in opts with key _ (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 values to args for add_opt in theAdditionalOptions: diff --git a/bin/runSalome.py b/bin/runSalome.py index 071340362..ce89f8269 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -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'):