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)
# 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
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
o_play, # Reproducing test script with help of TestRecorder
o_gdb,
o_ddd,
+ o_shutdown,
]
#std_options = ["gui", "desktop", "log_file", "py_scripts", "resources",
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:
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'):