X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=bin%2FlaunchConfigureParser.py;h=cfb247f619dcbfef936d53549b6061ca2a5d0519;hb=f6f9c5bd0eb17ab1f0cb40d4761995f48f093526;hp=4d484ffd0918e0685ecec0d9a0a534e547c55f2d;hpb=6d9c102060aa7ad2e25f3e252ab2c1d57de4d38f;p=modules%2Fkernel.git diff --git a/bin/launchConfigureParser.py b/bin/launchConfigureParser.py index 4d484ffd0..cfb247f61 100755 --- a/bin/launchConfigureParser.py +++ b/bin/launchConfigureParser.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE # # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -7,7 +7,7 @@ # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either -# version 2.1 of the License. +# version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -28,6 +28,8 @@ import types from salome_utils import verbose, setVerbose, getPortNumber, getHomeDir +from salomeContextUtils import getScriptsAndArgs + # names of tags in XML configuration file doc_tag = "document" sec_tag = "section" @@ -66,6 +68,10 @@ valgrind_session_nam = "valgrind_session" shutdown_servers_nam = "shutdown_servers" foreground_nam = "foreground" wake_up_session_nam = "wake_up_session" +siman_nam = "siman" +siman_study_nam = "siman_study" +siman_scenario_nam = "siman_scenario" +siman_user_nam = "siman_user" # values in XML configuration file giving specific module parameters ( section) # which are stored in opts with key _ (eg SMESH_plugins) @@ -252,7 +258,8 @@ def process_containers_params( standalone, embedded ): section_to_skip = "" class xml_parser: - def __init__(self, fileName, _opts, _importHistory=[] ): + def __init__(self, fileName, _opts, _importHistory): + #warning _importHistory=[] is NOT good: is NOT empty,reinitialized after first call if verbose(): print "Configure parser: processing %s ..." % fileName self.fileName = os.path.abspath(fileName) self.importHistory = _importHistory @@ -536,21 +543,6 @@ def CreateOptionParser (theAdditionalOptions=[]): dest="log_file", help=help_str) - # Execute python scripts. Default: None. - help_str = "Python script(s) to be imported. Python scripts are imported " - help_str += "in the order of their appearance. In GUI mode python scripts " - help_str += "are imported in the embedded python interpreter of current study, " - help_str += "otherwise in an external python interpreter. " - help_str += "Note: this option is obsolete. Instead you can pass Python script(s) " - help_str += "directly as positional parameter." - o_u = optparse.Option("-u", - "--execute", - metavar="", - type="string", - action="append", - dest="py_scripts", - help=help_str) - # Configuration XML file. Default: see defaultUserFile() function help_str = "Parse application settings from the " help_str += "instead of default %s" % defaultUserFile() @@ -781,16 +773,49 @@ def CreateOptionParser (theAdditionalOptions=[]): o_port = optparse.Option("--port", metavar="", type="int", - action="store", + action="store", dest="use_port", - help=help_str) + help=help_str) + + # SIMAN launch mode + help_str = "Special mode for interacting with SIMAN." + o_siman = optparse.Option("--siman", + action="store_true", + dest="siman", + help=help_str) + + # SIMAN study + help_str = "SIMAN study identifier." + o_siman_study = optparse.Option("--siman-study", + metavar="", + type="string", + action="store", + dest="siman_study", + help=help_str) + + # SIMAN scenario + help_str = "SIMAN scenario identifier." + o_siman_scenario = optparse.Option("--siman-scenario", + metavar="", + type="string", + action="store", + dest="siman_scenario", + help=help_str) + + # SIMAN user + help_str = "SIMAN user identifier." + o_siman_user = optparse.Option("--siman-user", + metavar="", + type="string", + action="store", + dest="siman_user", + help=help_str) # All options opt_list = [o_t,o_g, # GUI/Terminal o_d,o_o, # Desktop o_b, # Batch o_l,o_f, # Use logger or log-file - o_u, # Execute python scripts o_r, # Configuration XML file o_x, # xterm o_m, # Modules @@ -815,16 +840,22 @@ def CreateOptionParser (theAdditionalOptions=[]): o_wake_up, o_slm, # Server launch mode o_port, # Use port + o_siman, # Siman launch mode + o_siman_study, # Siman study + o_siman_scenario,# Siman scenario + o_siman_user, # Siman user ] - #std_options = ["gui", "desktop", "log_file", "py_scripts", "resources", + #std_options = ["gui", "desktop", "log_file", "resources", # "xterm", "modules", "embedded", "standalone", # "portkill", "killall", "interp", "splash", # "catch_exceptions", "print_port", "save_config", "ns_port_log_file"] opt_list += theAdditionalOptions - a_usage = "%prog [options] [STUDY_FILE] [PYTHON_FILE [PYTHON_FILE ...]]" + a_usage = """%prog [options] [STUDY_FILE] [PYTHON_FILE [args] [PYTHON_FILE [args]...]] +Python file arguments, if any, must be comma-separated (without blank characters) and prefixed by "args:" (without quotes), e.g. myscript.py args:arg1,arg2=val,... +""" version_str = "Salome %s" % version() pars = optparse.OptionParser(usage=a_usage, version=version_str, option_list=opt_list) @@ -892,6 +923,13 @@ def get_env(theAdditionalOptions=[], appname=salomeappname, cfgname=salomecfgnam from searchFreePort import searchFreePort searchFreePort({}) print "port:%s"%(os.environ['NSPORT']) + + try: + import PortManager + PortManager.releasePort(os.environ['NSPORT']) + except ImportError: + pass + sys.exit(0) pass @@ -930,7 +968,7 @@ def get_env(theAdditionalOptions=[], appname=salomeappname, cfgname=salomecfgnam if verbose(): print "Configure parser: Warning : can not find configuration file %s" % filename else: try: - p = xml_parser(filename, _opts) + p = xml_parser(filename, _opts, []) _opts = p.opts except: if verbose(): print "Configure parser: Error : can not read configuration file %s" % filename @@ -948,7 +986,7 @@ def get_env(theAdditionalOptions=[], appname=salomeappname, cfgname=salomecfgnam if verbose(): print "Configure parser: Warning : can not find user configuration file" else: try: - p = xml_parser(user_config, _opts) + p = xml_parser(user_config, _opts, []) _opts = p.opts except: if verbose(): print 'Configure parser: Error : can not read user configuration file' @@ -983,7 +1021,7 @@ def get_env(theAdditionalOptions=[], appname=salomeappname, cfgname=salomecfgnam # apply command-line options to the arguments # each option given in command line overrides the option from xml config file # - # Options: gui, desktop, log_file, py_scripts, resources, + # Options: gui, desktop, log_file, resources, # xterm, modules, embedded, standalone, # portkill, killall, interp, splash, # catch_exceptions, pinter @@ -1023,22 +1061,21 @@ def get_env(theAdditionalOptions=[], appname=salomeappname, cfgname=salomecfgnam if cmd_opts.ns_port_log_file is not None: args["ns_port_log_file"] = cmd_opts.ns_port_log_file - # Python scripts - args[script_nam] = [] - if cmd_opts.py_scripts is not None: - listlist = cmd_opts.py_scripts - for listi in listlist: - if os.sys.platform == 'win32': - args[script_nam] += re.split( "[;,]", listi) - else: - args[script_nam] += re.split( "[:;,]", listi) + # Study files for arg in cmd_args: - if arg[-3:] == ".py": - args[script_nam].append(arg) - elif not args["study_hdf"]: + if arg[-4:] == ".hdf" and not args["study_hdf"]: args["study_hdf"] = arg - pass - pass + + # Python scripts + args[script_nam] = getScriptsAndArgs(cmd_args) + new_args = [] + if args[gui_nam] and args["session_gui"]: + for d in args[script_nam]: + for s, a in d.items(): + v = re.sub(r'^python.*\s+', r'', s) + new_args.append({v:a}) + # + args[script_nam] = new_args # xterm if cmd_opts.xterm is not None: args[xterm_nam] = cmd_opts.xterm @@ -1122,6 +1159,16 @@ def get_env(theAdditionalOptions=[], appname=salomeappname, cfgname=salomecfgnam if cmd_opts.wake_up_session is not None: args[wake_up_session_nam] = cmd_opts.wake_up_session + # siman options + if cmd_opts.siman is not None: + args[siman_nam] = cmd_opts.siman + if cmd_opts.siman_study is not None: + args[siman_study_nam] = cmd_opts.siman_study + if cmd_opts.siman_scenario is not None: + args[siman_scenario_nam] = cmd_opts.siman_scenario + if cmd_opts.siman_user is not None: + args[siman_user_nam] = cmd_opts.siman_user + #################################################### # Add values to args for add_opt in theAdditionalOptions: @@ -1150,6 +1197,9 @@ def get_env(theAdditionalOptions=[], appname=salomeappname, cfgname=salomecfgnam #elif os.path.exists( "%s/%s.xml"%(d2, appname) ): elif os.path.exists( "%s/%s.xml"%(d2, salomeappname) ): dirs.append( d2 ) + else: + #print "* '"+m+"' should be deleted from ",args[modules_nam] + pass # Test if cmd_opts.test_script_file is not None: