Back to index

salome-kernel  6.5.0
Classes | Functions | Variables
launchConfigureParser Namespace Reference

Classes

class  xml_parser

Functions

def version
 Get the application version Uses GUI_ROOT_DIR (or KERNEL_ROOT_DIR in batch mode) +/bin/salome/VERSION file.
def version_id
 Calculate and return configuration file unique ID For example: for SALOME version 3.1.0a1 the id is 300999701.
def defaultUserFile
 Get default user configuration file name For SALOME, it is:
def userFile
 Get user configuration file name.
def process_containers_params
def check_embedded
def check_standalone
def store_boolean
def CreateOptionParser
def get_env

Variables

string doc_tag = "document"
string sec_tag = "section"
string par_tag = "parameter"
string import_tag = "import"
string nam_att = "name"
string val_att = "value"
string lanch_nam = "launch"
string help_nam = "help"
string gui_nam = "gui"
string splash_nam = "splash"
string logger_nam = "logger"
string xterm_nam = "xterm"
string file_nam = "file"
string portkill_nam = "portkill"
string killall_nam = "killall"
string modules_nam = "modules"
string embedded_nam = "embedded"
string standalone_nam = "standalone"
string key_nam = "key"
string terminal_nam = "terminal"
string interp_nam = "interp"
string except_nam = "noexcepthandler"
string pinter_nam = "pinter"
string batch_nam = "batch"
string test_nam = "test"
string play_nam = "play"
string gdb_session_nam = "gdb_session"
string ddd_session_nam = "ddd_session"
string valgrind_session_nam = "valgrind_session"
string shutdown_servers_nam = "shutdown_servers"
string foreground_nam = "foreground"
string wake_up_session_nam = "wake_up_session"
string plugins_nam = "plugins"
string appname_nam = "appname"
string port_nam = "port"
string salomecfgname = "salome"
string salomeappname = "SalomeApp"
string script_nam = "pyscript"
list embedded_choices = [ "registry", "study", "moduleCatalog", "cppContainer", "SalomeAppEngine" ]
list standalone_choices = [ "registry", "study", "moduleCatalog", "cppContainer", "pyContainer"]
tuple boolKeys = ( gui_nam, splash_nam, logger_nam, file_nam, xterm_nam, portkill_nam, killall_nam, except_nam, pinter_nam, shutdown_servers_nam )
tuple intKeys = ( interp_nam, )
tuple listKeys = ( embedded_nam, key_nam, modules_nam, standalone_nam, plugins_nam )
string section_to_skip = ""
 XML reader for launch configuration file usage.
dictionary booleans
tuple boolean_choices = booleans.keys()
dictionary args = {}
 Get the environment.

Function Documentation

def launchConfigureParser.check_embedded (   option,
  opt,
  value,
  parser 
)

Definition at line 399 of file launchConfigureParser.py.

00399 
00400 def check_embedded(option, opt, value, parser):
00401     from optparse import OptionValueError
00402     assert value is not None
00403     if parser.values.embedded:
00404         embedded = filter( lambda a: a.strip(), re.split( "[:;,]", parser.values.embedded ) )
00405     else:
00406         embedded = []
00407     if parser.values.standalone:
00408         standalone = filter( lambda a: a.strip(), re.split( "[:;,]", parser.values.standalone ) )
00409     else:
00410         standalone = []
00411     vals = filter( lambda a: a.strip(), re.split( "[:;,]", value ) )
00412     for v in vals:
00413         if v not in embedded_choices:
00414             raise OptionValueError( "option %s: invalid choice: %r (choose from %s)" % ( opt, v, ", ".join( map( repr, embedded_choices ) ) ) )
00415         if v not in embedded:
00416             embedded.append( v )
00417             if v in standalone:
00418                 del standalone[ standalone.index( v ) ]
00419                 pass
00420     parser.values.embedded = ",".join( embedded )
00421     parser.values.standalone = ",".join( standalone )
00422     pass

def launchConfigureParser.check_standalone (   option,
  opt,
  value,
  parser 
)

Definition at line 423 of file launchConfigureParser.py.

00423 
00424 def check_standalone(option, opt, value, parser):
00425     from optparse import OptionValueError
00426     assert value is not None
00427     if parser.values.embedded:
00428         embedded = filter( lambda a: a.strip(), re.split( "[:;,]", parser.values.embedded ) )
00429     else:
00430         embedded = []
00431     if parser.values.standalone:
00432         standalone = filter( lambda a: a.strip(), re.split( "[:;,]", parser.values.standalone ) )
00433     else:
00434         standalone = []
00435     vals = filter( lambda a: a.strip(), re.split( "[:;,]", value ) )
00436     for v in vals:
00437         if v not in standalone_choices:
00438             raise OptionValueError( "option %s: invalid choice: %r (choose from %s)" % ( opt, v, ", ".join( map( repr, standalone_choices ) ) ) )
00439         if v not in standalone:
00440             standalone.append( v )
00441             if v in embedded:
00442                 del embedded[ embedded.index( v ) ]
00443                 pass
00444     parser.values.embedded = ",".join( embedded )
00445     parser.values.standalone = ",".join( standalone )
00446     pass

def launchConfigureParser.CreateOptionParser (   theAdditionalOptions = [])

Definition at line 461 of file launchConfigureParser.py.

00461 
00462 def CreateOptionParser (theAdditionalOptions=[]):
00463     # GUI/Terminal. Default: GUI
00464     help_str = "Launch without GUI (in the terminal mode)."
00465     o_t = optparse.Option("-t",
00466                           "--terminal",
00467                           action="store_false",
00468                           dest="gui",
00469                           help=help_str)
00470 
00471     help_str = "Launch in Batch Mode. (Without GUI on batch machine)"
00472     o_b = optparse.Option("-b",
00473                           "--batch",
00474                           action="store_true",
00475                           dest="batch",
00476                           help=help_str)
00477 
00478     help_str = "Launch in GUI mode [default]."
00479     o_g = optparse.Option("-g",
00480                           "--gui",
00481                           action="store_true",
00482                           dest="gui",
00483                           help=help_str)
00484 
00485     # Show Desktop (inly in GUI mode). Default: True
00486     help_str  = "1 to activate GUI desktop [default], "
00487     help_str += "0 to not activate GUI desktop (Session_Server starts, but GUI is not shown). "
00488     help_str += "Ignored in the terminal mode."
00489     o_d = optparse.Option("-d",
00490                           "--show-desktop",
00491                           metavar="<1/0>",
00492                           #type="choice", choices=boolean_choices,
00493                           type="string",
00494                           action="callback", callback=store_boolean, callback_args=('desktop',),
00495                           dest="desktop",
00496                           help=help_str)
00497     help_str  = "Do not activate GUI desktop (Session_Server starts, but GUI is not shown). "
00498     help_str += "The same as --show-desktop=0."
00499     o_o = optparse.Option("-o",
00500                           "--hide-desktop",
00501                           action="store_false",
00502                           dest="desktop",
00503                           help=help_str)
00504 
00505     # Use logger or log-file. Default: nothing.
00506     help_str = "Redirect messages to the CORBA collector."
00507     #o4 = optparse.Option("-l", "--logger", action="store_true", dest="logger", help=help_str)
00508     o_l = optparse.Option("-l",
00509                           "--logger",
00510                           action="store_const", const="CORBA",
00511                           dest="log_file",
00512                           help=help_str)
00513     help_str = "Redirect messages to the <log-file>"
00514     o_f = optparse.Option("-f",
00515                           "--log-file",
00516                           metavar="<log-file>",
00517                           type="string",
00518                           action="store",
00519                           dest="log_file",
00520                           help=help_str)
00521 
00522     # Execute python scripts. Default: None.
00523     help_str  = "Python script(s) to be imported. Python scripts are imported "
00524     help_str += "in the order of their appearance. In GUI mode python scripts "
00525     help_str += "are imported in the embedded python interpreter of current study, "
00526     help_str += "otherwise in an external python interpreter. "
00527     help_str += "Note: this option is obsolete. Instead you can pass Python script(s) "
00528     help_str += "directly as positional parameter."
00529     o_u = optparse.Option("-u",
00530                           "--execute",
00531                           metavar="<script1,script2,...>",
00532                           type="string",
00533                           action="append",
00534                           dest="py_scripts",
00535                           help=help_str)
00536 
00537     # Configuration XML file. Default: see defaultUserFile() function
00538     help_str  = "Parse application settings from the <file> "
00539     help_str += "instead of default %s" % defaultUserFile()
00540     o_r = optparse.Option("-r",
00541                           "--resources",
00542                           metavar="<file>",
00543                           type="string",
00544                           action="store",
00545                           dest="resources",
00546                           help=help_str)
00547 
00548     # Use own xterm for each server. Default: False.
00549     help_str = "Launch each SALOME server in own xterm console"
00550     o_x = optparse.Option("-x",
00551                           "--xterm",
00552                           action="store_true",
00553                           dest="xterm",
00554                           help=help_str)
00555 
00556     # Modules. Default: Like in configuration files.
00557     help_str  = "SALOME modules list (where <module1>, <module2> are the names "
00558     help_str += "of SALOME modules which should be available in the SALOME session)"
00559     o_m = optparse.Option("-m",
00560                           "--modules",
00561                           metavar="<module1,module2,...>",
00562                           type="string",
00563                           action="append",
00564                           dest="modules",
00565                           help=help_str)
00566 
00567     # Embedded servers. Default: Like in configuration files.
00568     help_str  = "CORBA servers to be launched in the Session embedded mode. "
00569     help_str += "Valid values for <serverN>: %s " % ", ".join( embedded_choices )
00570     help_str += "[by default the value from the configuration files is used]"
00571     o_e = optparse.Option("-e",
00572                           "--embedded",
00573                           metavar="<server1,server2,...>",
00574                           type="string",
00575                           action="callback",
00576                           dest="embedded",
00577                           callback=check_embedded,
00578                           help=help_str)
00579 
00580     # Standalone servers. Default: Like in configuration files.
00581     help_str  = "CORBA servers to be launched in the standalone mode (as separate processes). "
00582     help_str += "Valid values for <serverN>: %s " % ", ".join( standalone_choices )
00583     help_str += "[by default the value from the configuration files is used]"
00584     o_s = optparse.Option("-s",
00585                           "--standalone",
00586                           metavar="<server1,server2,...>",
00587                           type="string",
00588                           action="callback",
00589                           dest="standalone",
00590                           callback=check_standalone,
00591                           help=help_str)
00592 
00593     # Kill with port. Default: False.
00594     help_str = "Kill SALOME with the current port"
00595     o_p = optparse.Option("-p",
00596                           "--portkill",
00597                           action="store_true",
00598                           dest="portkill",
00599                           help=help_str)
00600 
00601     # Kill all. Default: False.
00602     help_str = "Kill all running SALOME sessions"
00603     o_k = optparse.Option("-k",
00604                           "--killall",
00605                           action="store_true",
00606                           dest="killall",
00607                           help=help_str)
00608 
00609     # Additional python interpreters. Default: 0.
00610     help_str  = "The number of additional external python interpreters to run. "
00611     help_str += "Each additional python interpreter is run in separate "
00612     help_str += "xterm session with properly set SALOME environment"
00613     o_i = optparse.Option("-i",
00614                           "--interp",
00615                           metavar="<N>",
00616                           type="int",
00617                           action="store",
00618                           dest="interp",
00619                           help=help_str)
00620 
00621     # Splash. Default: True.
00622     help_str  = "1 to display splash screen [default], "
00623     help_str += "0 to disable splash screen. "
00624     help_str += "This option is ignored in the terminal mode. "
00625     help_str += "It is also ignored if --show-desktop=0 option is used."
00626     o_z = optparse.Option("-z",
00627                           "--splash",
00628                           metavar="<1/0>",
00629                           #type="choice", choices=boolean_choices,
00630                           type="string",
00631                           action="callback", callback=store_boolean, callback_args=('splash',),
00632                           dest="splash",
00633                           help=help_str)
00634 
00635     # Catch exceptions. Default: True.
00636     help_str  = "1 (yes,true,on,ok) to enable centralized exception handling [default], "
00637     help_str += "0 (no,false,off,cancel) to disable centralized exception handling."
00638     o_c = optparse.Option("-c",
00639                           "--catch-exceptions",
00640                           metavar="<1/0>",
00641                           #type="choice", choices=boolean_choices,
00642                           type="string",
00643                           action="callback", callback=store_boolean, callback_args=('catch_exceptions',),
00644                           dest="catch_exceptions",
00645                           help=help_str)
00646 
00647     # Print free port and exit
00648     help_str = "Print free port and exit"
00649     o_a = optparse.Option("--print-port",
00650                           action="store_true",
00651                           dest="print_port", default=False,
00652                           help=help_str)
00653 
00654     # Do not relink ${HOME}/.omniORB_last.cfg
00655     help_str = "Do not save current configuration ${HOME}/.omniORB_last.cfg"
00656     o_n = optparse.Option("--nosave-config",
00657                           action="store_false",
00658                           dest="save_config", default=True,
00659                           help=help_str)
00660 
00661     # Launch with interactive python console. Default: False.
00662     help_str = "Launch with interactive python console."
00663     o_pi = optparse.Option("--pinter",
00664                           action="store_true",
00665                           dest="pinter",
00666                           help=help_str)
00667 
00668     # Print Naming service port into a user file. Default: False.
00669     help_str = "Print Naming Service Port into a user file."
00670     o_nspl = optparse.Option("--ns-port-log",
00671                              metavar="<ns_port_log_file>",
00672                              type="string",
00673                              action="store",
00674                              dest="ns_port_log_file",
00675                              help=help_str)
00676 
00677     # Write/read test script file with help of TestRecorder. Default: False.
00678     help_str = "Write/read test script file with help of TestRecorder."
00679     o_test = optparse.Option("--test",
00680                              metavar="<test_script_file>",
00681                              type="string",
00682                              action="store",
00683                              dest="test_script_file",
00684                              help=help_str)
00685 
00686     # Reproducing test script with help of TestRecorder. Default: False.
00687     help_str = "Reproducing test script with help of TestRecorder."
00688     o_play = optparse.Option("--play",
00689                              metavar="<play_script_file>",
00690                              type="string",
00691                              action="store",
00692                              dest="play_script_file",
00693                              help=help_str)
00694 
00695     # gdb session
00696     help_str = "Launch session with gdb"
00697     o_gdb = optparse.Option("--gdb-session",
00698                             action="store_true",
00699                             dest="gdb_session", default=False,
00700                             help=help_str)
00701 
00702     # ddd session
00703     help_str = "Launch session with ddd"
00704     o_ddd = optparse.Option("--ddd-session",
00705                             action="store_true",
00706                             dest="ddd_session", default=False,
00707                             help=help_str)
00708 
00709 
00710     # valgrind session
00711     help_str = "Launch session with valgrind $VALGRIND_OPTIONS"
00712     o_valgrind = optparse.Option("--valgrind-session",
00713                                  action="store_true",
00714                                  dest="valgrind_session", default=False,
00715                                  help=help_str)
00716 
00717     # shutdown-servers. Default: False.
00718     help_str  = "1 to shutdown standalone servers when leaving python interpreter, "
00719     help_str += "0 to keep the standalone servers as daemon [default]. "
00720     help_str += "This option is only useful in batchmode "
00721     help_str += "(terminal mode or without showing desktop)."
00722     o_shutdown = optparse.Option("--shutdown-servers",
00723                                  metavar="<1/0>",
00724                                  #type="choice", choices=boolean_choices,
00725                                  type="string",
00726                                  action="callback", callback=store_boolean, callback_args=('shutdown_servers',),
00727                                  dest="shutdown_servers",
00728                                  help=help_str)
00729 
00730     # foreground. Default: True.
00731     help_str  = "0 and runSalome exits after have launched the gui, "
00732     help_str += "1 to launch runSalome in foreground mode [default]."
00733     o_foreground = optparse.Option("--foreground",
00734                                    metavar="<1/0>",
00735                                    #type="choice", choices=boolean_choices,
00736                                    type="string",
00737                                    action="callback", callback=store_boolean, callback_args=('foreground',),
00738                                    dest="foreground",
00739                                    help=help_str)
00740 
00741     # wake up session
00742     help_str  = "Wake up a previously closed session. "
00743     help_str += "The session object is found in the naming service pointed by the variable OMNIORB_CONFIG. "
00744     help_str += "If this variable is not setted, the last configuration is taken. "
00745     o_wake_up = optparse.Option("--wake-up-session",
00746                                 action="store_true",
00747                                 dest="wake_up_session", default=False,
00748                                 help=help_str)
00749 
00750     # server launch mode
00751     help_str = "Mode used to launch server processes (daemon or fork)."
00752     o_slm = optparse.Option("--server-launch-mode",
00753                             metavar="<server_launch_mode>",
00754                             type="choice",
00755                             choices=["daemon","fork"],
00756                             action="store",
00757                             dest="server_launch_mode",
00758                             help=help_str)
00759 
00760     # All options
00761     opt_list = [o_t,o_g, # GUI/Terminal
00762                 o_d,o_o, # Desktop
00763                 o_b,     # Batch
00764                 o_l,o_f, # Use logger or log-file
00765                 o_u,     # Execute python scripts
00766                 o_r,     # Configuration XML file
00767                 o_x,     # xterm
00768                 o_m,     # Modules
00769                 o_e,     # Embedded servers
00770                 o_s,     # Standalone servers
00771                 o_p,     # Kill with port
00772                 o_k,     # Kill all
00773                 o_i,     # Additional python interpreters
00774                 o_z,     # Splash
00775                 o_c,     # Catch exceptions
00776                 o_a,     # Print free port and exit
00777                 o_n,     # --nosave-config
00778                 o_pi,    # Interactive python console
00779                 o_nspl,
00780                 o_test,  # Write/read test script file with help of TestRecorder
00781                 o_play,  # Reproducing test script with help of TestRecorder
00782                 o_gdb,
00783                 o_ddd,
00784                 o_valgrind,
00785                 o_shutdown,
00786                 o_foreground,
00787                 o_wake_up,
00788                 o_slm,   # Server launch mode
00789                 ]
00790 
00791     #std_options = ["gui", "desktop", "log_file", "py_scripts", "resources",
00792     #               "xterm", "modules", "embedded", "standalone",
00793     #               "portkill", "killall", "interp", "splash",
00794     #               "catch_exceptions", "print_port", "save_config", "ns_port_log_file"]
00795 
00796     opt_list += theAdditionalOptions
00797 
00798     a_usage = "%prog [options] [STUDY_FILE] [PYTHON_FILE [PYTHON_FILE ...]]"
00799     version_str = "Salome %s" % version()
00800     pars = optparse.OptionParser(usage=a_usage, version=version_str, option_list=opt_list)
00801 
00802     return pars
00803 
00804 # -----------------------------------------------------------------------------

Here is the call graph for this function:

Here is the caller graph for this function:

def launchConfigureParser.defaultUserFile (   appname = salomeappname,
  cfgname = salomecfgname 
)

Get default user configuration file name For SALOME, it is:

  • on Linux: ~/.config/salome/.SalomeApprc.[version]
  • on Windows: ~/SalomeApp.xml.[version] where [version] is a version number

Definition at line 147 of file launchConfigureParser.py.

00147 
00148 def defaultUserFile(appname=salomeappname, cfgname=salomecfgname):
00149     v = version()
00150     if v: v = ".%s" % v
00151     if sys.platform == "win32":
00152       filename = os.path.join(getHomeDir(), "%s.xml%s" % (appname, v))
00153     else:
00154         if cfgname:
00155             filename = os.path.join(getHomeDir(), ".config", cfgname, ".%src%s" % (appname, v))
00156             pass
00157         else:
00158             filename = os.path.join(getHomeDir(), ".%src%s" % (appname, v))
00159             pass
00160         pass
00161     return filename

Here is the call graph for this function:

Here is the caller graph for this function:

def launchConfigureParser.get_env (   theAdditionalOptions = [],
  appname = salomeappname,
  cfgname = salomecfgname 
)

Definition at line 813 of file launchConfigureParser.py.

00813 
00814 def get_env(theAdditionalOptions=[], appname=salomeappname, cfgname=salomecfgname):
00815     ###
00816     # Collect launch configuration files:
00817     # - The environment variable "<appname>Config" (SalomeAppConfig) which can
00818     #   define a list of directories (separated by ':' or ';' symbol) is checked
00819     # - If the environment variable "<appname>Config" is not set, only
00820     #   ${GUI_ROOT_DIR}/share/salome/resources/gui is inspected
00821     # - ${GUI_ROOT_DIR}/share/salome/resources/gui directory is always inspected
00822     #   so it is not necessary to put it in the "<appname>Config" variable
00823     # - The directories which are inspected are checked for files "<appname?salomeappname>.xml"
00824     #  (SalomeApp.xml) which define SALOME configuration
00825     # - These directories are analyzed beginning from the last one in the list,
00826     #   so the first directory listed in "<appname>Config" environment variable
00827     #   has higher priority: it means that if some configuration options
00828     #   is found in the next analyzed cofiguration file - it will be replaced
00829     # - The last configuration file which is parsed is user configuration file
00830     #   situated in the home directory (if it exists):
00831     #   * ~/.config/salome/.<appname>rc[.<version>]" for Linux (e.g. ~/.config/salome/.SalomeApprc.6.4.0)
00832     #   * ~/<appname>.xml[.<version>] for Windows (e.g. ~/SalomeApp.xml.6.4.0)
00833     # - Command line options have the highest priority and replace options
00834     #   specified in configuration file(s)
00835     ###
00836 
00837     global args
00838     config_var = appname+'Config'
00839 
00840     separator = ":"
00841     if os.sys.platform == 'win32':
00842         separator = ";"
00843 
00844     # check KERNEL_ROOT_DIR
00845     try:
00846         kernel_root_dir=os.environ["KERNEL_ROOT_DIR"]
00847     except:
00848         print """
00849         For each SALOME module, the environment variable <moduleN>_ROOT_DIR must be set.
00850         KERNEL_ROOT_DIR is mandatory.
00851         """
00852         sys.exit(1)
00853         pass
00854 
00855     ############################
00856     # parse command line options
00857     pars = CreateOptionParser(theAdditionalOptions)
00858     (cmd_opts, cmd_args) = pars.parse_args(sys.argv[1:])
00859     ############################
00860 
00861     # Process --print-port option
00862     if cmd_opts.print_port:
00863         from runSalome import searchFreePort
00864         searchFreePort({})
00865         print "port:%s"%(os.environ['NSPORT'])
00866         sys.exit(0)
00867         pass
00868 
00869     # set resources variable SalomeAppConfig if it is not set yet
00870     dirs = []
00871     if os.getenv(config_var):
00872         if sys.platform == 'win32':
00873             dirs += re.split(';', os.getenv(config_var))
00874         else:
00875             dirs += re.split('[;|:]', os.getenv(config_var))
00876 
00877     gui_available = True
00878     if os.getenv("GUI_ROOT_DIR") and os.path.isdir( os.getenv("GUI_ROOT_DIR") + "/share/salome/resources/gui" ):
00879         dirs += [os.getenv("GUI_ROOT_DIR") + "/share/salome/resources/gui"]
00880         pass
00881     else:
00882         gui_available = False
00883         if os.getenv("KERNEL_ROOT_DIR") and os.path.isdir( os.getenv("KERNEL_ROOT_DIR") + "/bin/salome/appliskel" ):
00884             dirs += [os.getenv("KERNEL_ROOT_DIR") + "/bin/salome/appliskel"]
00885         pass
00886     os.environ[config_var] = separator.join(dirs)
00887 
00888     dirs.reverse() # reverse order, like in "path" variable - FILO-style processing
00889 
00890     try:
00891         dirs.remove('') # to remove empty dirs if the variable terminate by ":" or if there are "::" inside
00892     except:
00893         pass
00894 
00895     _opts = {} # associative array of options to be filled
00896 
00897     # parse SalomeApp.xml files in directories specified by SalomeAppConfig env variable
00898     for dir in dirs:
00899         filename = os.path.join(dir, appname+'.xml')
00900         if not os.path.exists(filename):
00901             if verbose(): print "Configure parser: Warning : can not find configuration file %s" % filename
00902         else:
00903             try:
00904                 p = xml_parser(filename, _opts)
00905                 _opts = p.opts
00906             except:
00907                 if verbose(): print "Configure parser: Error : can not read configuration file %s" % filename
00908             pass
00909 
00910     # parse user configuration file
00911     # It can be set via --resources=<file> command line option
00912     # or is given from default location (see defaultUserFile() function)
00913     # If user file for the current version is not found the nearest to it is used
00914     user_config = cmd_opts.resources
00915     if not user_config:
00916         user_config = userFile(appname, cfgname)
00917         if verbose(): print "Configure parser: user configuration file is", user_config
00918     if not user_config or not os.path.exists(user_config):
00919         if verbose(): print "Configure parser: Warning : can not find user configuration file"
00920     else:
00921         try:
00922             p = xml_parser(user_config, _opts)
00923             _opts = p.opts
00924         except:
00925             if verbose(): print 'Configure parser: Error : can not read user configuration file'
00926             user_config = ""
00927 
00928     args = _opts
00929 
00930     args['user_config'] = user_config
00931     #print "User Configuration file: ", args['user_config']
00932 
00933     # set default values for options which are NOT set in config files
00934     for aKey in listKeys:
00935         if not args.has_key( aKey ):
00936             args[aKey]=[]
00937 
00938     for aKey in boolKeys:
00939         if not args.has_key( aKey ):
00940             args[aKey]=0
00941 
00942     if args[file_nam]:
00943         afile=args[file_nam]
00944         args[file_nam]=[afile]
00945 
00946     args[appname_nam] = appname
00947 
00948     # get the port number
00949     my_port = getPortNumber()
00950 
00951     args[port_nam] = my_port
00952 
00953     ####################################################
00954     # apply command-line options to the arguments
00955     # each option given in command line overrides the option from xml config file
00956     #
00957     # Options: gui, desktop, log_file, py_scripts, resources,
00958     #          xterm, modules, embedded, standalone,
00959     #          portkill, killall, interp, splash,
00960     #          catch_exceptions, pinter
00961 
00962     # GUI/Terminal, Desktop, Splash, STUDY_HDF
00963     args["session_gui"] = False
00964     args[batch_nam] = False
00965     args["study_hdf"] = None
00966     if cmd_opts.gui is not None:
00967         args[gui_nam] = cmd_opts.gui
00968     if cmd_opts.batch is not None:
00969         args[batch_nam] = True
00970 
00971     if not gui_available:
00972         args[gui_nam] = False
00973 
00974     if args[gui_nam]:
00975         args["session_gui"] = True
00976         if cmd_opts.desktop is not None:
00977             args["session_gui"] = cmd_opts.desktop
00978             args[splash_nam]    = cmd_opts.desktop
00979         if args["session_gui"]:
00980             if cmd_opts.splash is not None:
00981                 args[splash_nam] = cmd_opts.splash
00982     else:
00983         args["session_gui"] = False
00984         args[splash_nam] = False
00985 
00986     # Logger/Log file
00987     if cmd_opts.log_file is not None:
00988         if cmd_opts.log_file == 'CORBA':
00989             args[logger_nam] = True
00990         else:
00991             args[file_nam] = [cmd_opts.log_file]
00992 
00993     # Naming Service port log file
00994     if cmd_opts.ns_port_log_file is not None:
00995       args["ns_port_log_file"] = cmd_opts.ns_port_log_file
00996 
00997     # Python scripts
00998     args[script_nam] = []
00999     if cmd_opts.py_scripts is not None:
01000         listlist = cmd_opts.py_scripts
01001         for listi in listlist:
01002             if os.sys.platform == 'win32':
01003                 args[script_nam] += re.split( "[;,]", listi)
01004             else:
01005                 args[script_nam] += re.split( "[:;,]", listi)
01006     for arg in cmd_args:
01007         if arg[-3:] == ".py":
01008             args[script_nam].append(arg)
01009         elif not args["study_hdf"]:
01010             args["study_hdf"] = arg
01011             pass
01012         pass
01013 
01014     # xterm
01015     if cmd_opts.xterm is not None: args[xterm_nam] = cmd_opts.xterm
01016 
01017     # Modules
01018     if cmd_opts.modules is not None:
01019         args[modules_nam] = []
01020         listlist = cmd_opts.modules
01021         for listi in listlist:
01022             args[modules_nam] += re.split( "[:;,]", listi)
01023     else:
01024         # if --modules (-m) command line option is not given
01025         # try SALOME_MODULES environment variable
01026         if os.getenv( "SALOME_MODULES" ):
01027             args[modules_nam] = re.split( "[:;,]", os.getenv( "SALOME_MODULES" ) )
01028             pass
01029 
01030     # Embedded
01031     if cmd_opts.embedded is not None:
01032         args[embedded_nam] = filter( lambda a: a.strip(), re.split( "[:;,]", cmd_opts.embedded ) )
01033 
01034     # Standalone
01035     if cmd_opts.standalone is not None:
01036         args[standalone_nam] = filter( lambda a: a.strip(), re.split( "[:;,]", cmd_opts.standalone ) )
01037 
01038     # Normalize the '--standalone' and '--embedded' parameters
01039     standalone, embedded = process_containers_params( args.get( standalone_nam ),
01040                                                       args.get( embedded_nam ) )
01041     if standalone is not None:
01042         args[ standalone_nam ] = standalone
01043     if embedded is not None:
01044         args[ embedded_nam ] = embedded
01045 
01046     # Kill
01047     if cmd_opts.portkill is not None: args[portkill_nam] = cmd_opts.portkill
01048     if cmd_opts.killall  is not None: args[killall_nam]  = cmd_opts.killall
01049 
01050     # Interpreter
01051     if cmd_opts.interp is not None:
01052         args[interp_nam] = cmd_opts.interp
01053 
01054     # Exceptions
01055     if cmd_opts.catch_exceptions is not None:
01056         args[except_nam] = not cmd_opts.catch_exceptions
01057 
01058     # Relink config file
01059     if cmd_opts.save_config is not None:
01060         args['save_config'] = cmd_opts.save_config
01061 
01062     # Interactive python console
01063     if cmd_opts.pinter is not None:
01064         args[pinter_nam] = cmd_opts.pinter
01065 
01066     # Gdb session in xterm
01067     if cmd_opts.gdb_session is not None:
01068         args[gdb_session_nam] = cmd_opts.gdb_session
01069 
01070     # Ddd session in xterm
01071     if cmd_opts.ddd_session is not None:
01072         args[ddd_session_nam] = cmd_opts.ddd_session
01073 
01074     # valgrind session
01075     if cmd_opts.valgrind_session is not None:
01076         args[valgrind_session_nam] = cmd_opts.valgrind_session
01077 
01078     # Shutdown servers
01079     if cmd_opts.shutdown_servers is None:
01080         args[shutdown_servers_nam] = 0
01081     else:
01082         args[shutdown_servers_nam] = cmd_opts.shutdown_servers
01083         pass
01084 
01085     # Foreground
01086     if cmd_opts.foreground is None:
01087         args[foreground_nam] = 1
01088     else:
01089         args[foreground_nam] = cmd_opts.foreground
01090         pass
01091 
01092     # wake up session
01093     if cmd_opts.wake_up_session is not None:
01094         args[wake_up_session_nam] = cmd_opts.wake_up_session
01095 
01096     ####################################################
01097     # Add <theAdditionalOptions> values to args
01098     for add_opt in theAdditionalOptions:
01099         cmd = "args[\"%s\"] = cmd_opts.%s"%(add_opt.dest,add_opt.dest)
01100         exec(cmd)
01101     ####################################################
01102 
01103     # disable signals handling
01104     if args[except_nam] == 1:
01105         os.environ["NOT_INTERCEPT_SIGNALS"] = "1"
01106         pass
01107 
01108     # now modify SalomeAppConfig environment variable
01109     # to take into account the SALOME modules
01110     if os.sys.platform == 'win32':
01111         dirs = re.split('[;]', os.environ[config_var] )
01112     else:
01113         dirs = re.split('[;|:]', os.environ[config_var] )
01114     for m in args[modules_nam]:
01115         if m not in ["KERNEL", "GUI", ""] and os.getenv("%s_ROOT_DIR"%m):
01116             d1 = os.getenv("%s_ROOT_DIR"%m) + "/share/salome/resources/" + m.lower()
01117             d2 = os.getenv("%s_ROOT_DIR"%m) + "/share/salome/resources"
01118             #if os.path.exists( "%s/%s.xml"%(d1, appname) ):
01119             if os.path.exists( "%s/%s.xml"%(d1, salomeappname) ):
01120                 dirs.append( d1 )
01121             #elif os.path.exists( "%s/%s.xml"%(d2, appname) ):
01122             elif os.path.exists( "%s/%s.xml"%(d2, salomeappname) ):
01123                 dirs.append( d2 )
01124 
01125     # Test
01126     if cmd_opts.test_script_file is not None:
01127         args[test_nam] = []
01128         filename = cmd_opts.test_script_file
01129         args[test_nam] += re.split( "[:;,]", filename )
01130 
01131     # Play
01132     if cmd_opts.play_script_file is not None:
01133         args[play_nam] = []
01134         filename = cmd_opts.play_script_file
01135         args[play_nam] += re.split( "[:;,]", filename )
01136 
01137     # Server launch command
01138     if cmd_opts.server_launch_mode is not None:
01139       args["server_launch_mode"] = cmd_opts.server_launch_mode
01140 
01141     # return arguments
01142     os.environ[config_var] = separator.join(dirs)
01143     #print "Args: ", args
01144     return args

Here is the call graph for this function:

Here is the caller graph for this function:

def launchConfigureParser.process_containers_params (   standalone,
  embedded 
)

Definition at line 213 of file launchConfigureParser.py.

00213 
00214 def process_containers_params( standalone, embedded ):
00215     # 1. filter inappropriate containers names
00216     if standalone is not None:
00217         standalone = filter( lambda x: x in standalone_choices, standalone )
00218     if embedded is not None:
00219         embedded   = filter( lambda x: x in embedded_choices,   embedded )
00220 
00221     # 2. remove containers appearing in 'standalone' parameter from the 'embedded'
00222     # parameter --> i.e. 'standalone' parameter has higher priority
00223     if standalone is not None and embedded is not None:
00224         embedded = filter( lambda x: x not in standalone, embedded )
00225 
00226     # 3. return corrected parameters values
00227     return standalone, embedded
00228 
00229 # -----------------------------------------------------------------------------

Here is the caller graph for this function:

def launchConfigureParser.store_boolean (   option,
  opt,
  value,
  parser,
  args 
)

Definition at line 447 of file launchConfigureParser.py.

00447 
00448 def store_boolean (option, opt, value, parser, *args):
00449     if isinstance(value, types.StringType):
00450         try:
00451             value_conv = booleans[value.strip().lower()]
00452             for attribute in args:
00453                 setattr(parser.values, attribute, value_conv)
00454         except KeyError:
00455             raise optparse.OptionValueError(
00456                 "option %s: invalid boolean value: %s (choose from %s)"
00457                 % (opt, value, boolean_choices))
00458     else:
00459         for attribute in args:
00460             setattr(parser.values, attribute, value)

def launchConfigureParser.userFile (   appname,
  cfgname 
)

Get user configuration file name.

Definition at line 165 of file launchConfigureParser.py.

00165 
00166 def userFile(appname, cfgname):
00167     # get app version
00168     v = version()
00169     if not v: return None                        # unknown version
00170     
00171     # get default user file name
00172     filename = defaultUserFile(appname, cfgname)
00173     if not filename: return None                 # default user file name is bad
00174     
00175     # check that default user file exists
00176     if os.path.exists(filename): return filename # user file is found
00177 
00178     # otherwise try to detect any appropriate user file
00179 
00180     # ... calculate default version id
00181     id0 = version_id(v)
00182     if not id0: return None                      # bad version id -> can't detect appropriate file
00183     
00184     # ... get all existing user preferences files
00185     if sys.platform == "win32":
00186         files = glob.glob(os.path.join(getHomeDir(), "%s.xml.*" % appname))
00187     else:
00188         files = []
00189         if cfgname: files += glob.glob(os.path.join(getHomeDir(), ".config", cfgname, ".%src.*" % appname))
00190         files             += glob.glob(os.path.join(getHomeDir(), ".%src.*" % appname))
00191         pass
00192 
00193     # ... loop through all files and find most appopriate file (with closest id)
00194     appr_id   = -1
00195     appr_file = ""
00196     for f in files:
00197         if sys.platform == "win32":
00198             match = re.search( r'%s\.xml\.([a-zA-Z0-9.]+)$'%appname, f )
00199         else:
00200             match = re.search( r'\.%src\.([a-zA-Z0-9.]+)$'%appname, f )
00201         if match:
00202             ver = version_id(match.group(1))
00203             if not ver: continue                 # bad version id -> skip file
00204             if appr_id < 0 or abs(appr_id-id0) > abs(ver-id0):
00205                 appr_id   = ver
00206                 appr_file = f
00207                 pass
00208             pass
00209         pass
00210     return appr_file
00211 
00212 # --

Here is the call graph for this function:

Here is the caller graph for this function:

Get the application version Uses GUI_ROOT_DIR (or KERNEL_ROOT_DIR in batch mode) +/bin/salome/VERSION file.

Definition at line 97 of file launchConfigureParser.py.

00097 
00098 def version():
00099     try:
00100         filename = None
00101         root_dir = os.environ.get( 'KERNEL_ROOT_DIR', '' ) # KERNEL_ROOT_DIR or "" if not found
00102         if root_dir and os.path.exists( root_dir + "/bin/salome/VERSION" ):
00103             filename = root_dir + "/bin/salome/VERSION"
00104         root_dir = os.environ.get( 'GUI_ROOT_DIR', '' )    # GUI_ROOT_DIR "" if not found
00105         if root_dir and os.path.exists( root_dir + "/bin/salome/VERSION" ):
00106             filename = root_dir + "/bin/salome/VERSION"
00107         if filename:
00108             str = open( filename, "r" ).readline() # str = "THIS IS SALOME - SALOMEGUI VERSION: 3.0.0"
00109             match = re.search( r':\s+([a-zA-Z0-9.]+)\s*$', str )
00110             if match :
00111                 return match.group( 1 )
00112     except:
00113         pass
00114     return ''

Here is the caller graph for this function:

Calculate and return configuration file unique ID For example: for SALOME version 3.1.0a1 the id is 300999701.

Definition at line 119 of file launchConfigureParser.py.

00119 
00120 def version_id(fname):
00121     major = minor = release = dev1 = dev2 = 0
00122     vers = fname.split(".")
00123     if len(vers) > 0: major = int(vers[0])
00124     if len(vers) > 1: minor = int(vers[1])
00125     if len(vers) > 2:
00126         mr = re.search(r'^([0-9]+)([A-Za-z]?)([0-9]*)',vers[2])
00127         if mr:
00128             release = int(mr.group(1))
00129             if mr.group(2).strip(): dev1 = ord(mr.group(2).strip())
00130             if mr.group(3).strip(): dev2 = int(mr.group(3).strip())
00131             pass
00132         pass
00133     dev = dev1 * 100 + dev2
00134     ver = major
00135     ver = ver * 100 + minor
00136     ver = ver * 100 + release
00137     ver = ver * 10000
00138     if dev > 0: ver = ver - 10000 + dev
00139     return ver

Here is the caller graph for this function:


Variable Documentation

Definition at line 75 of file launchConfigureParser.py.

dictionary launchConfigureParser.args = {}

Get the environment.

Definition at line 810 of file launchConfigureParser.py.

Definition at line 60 of file launchConfigureParser.py.

tuple launchConfigureParser.boolean_choices = booleans.keys()

Definition at line 397 of file launchConfigureParser.py.

Initial value:
00001 { '1': True , 'yes': True , 'y': True , 'on' : True , 'true' : True , 'ok'     : True,
00002              '0': False, 'no' : False, 'n': False, 'off': False, 'false': False, 'cancel' : False }

Definition at line 394 of file launchConfigureParser.py.

Definition at line 87 of file launchConfigureParser.py.

string launchConfigureParser.ddd_session_nam = "ddd_session"

Definition at line 64 of file launchConfigureParser.py.

string launchConfigureParser.doc_tag = "document"

Definition at line 32 of file launchConfigureParser.py.

list launchConfigureParser.embedded_choices = [ "registry", "study", "moduleCatalog", "cppContainer", "SalomeAppEngine" ]

Definition at line 82 of file launchConfigureParser.py.

Definition at line 52 of file launchConfigureParser.py.

string launchConfigureParser.except_nam = "noexcepthandler"

Definition at line 57 of file launchConfigureParser.py.

Definition at line 48 of file launchConfigureParser.py.

string launchConfigureParser.foreground_nam = "foreground"

Definition at line 67 of file launchConfigureParser.py.

string launchConfigureParser.gdb_session_nam = "gdb_session"

Definition at line 63 of file launchConfigureParser.py.

Definition at line 44 of file launchConfigureParser.py.

Definition at line 43 of file launchConfigureParser.py.

Definition at line 35 of file launchConfigureParser.py.

Definition at line 56 of file launchConfigureParser.py.

Definition at line 88 of file launchConfigureParser.py.

Definition at line 54 of file launchConfigureParser.py.

Definition at line 50 of file launchConfigureParser.py.

Definition at line 42 of file launchConfigureParser.py.

Definition at line 91 of file launchConfigureParser.py.

Definition at line 46 of file launchConfigureParser.py.

Definition at line 51 of file launchConfigureParser.py.

Definition at line 38 of file launchConfigureParser.py.

string launchConfigureParser.par_tag = "parameter"

Definition at line 34 of file launchConfigureParser.py.

Definition at line 59 of file launchConfigureParser.py.

Definition at line 62 of file launchConfigureParser.py.

Definition at line 72 of file launchConfigureParser.py.

Definition at line 76 of file launchConfigureParser.py.

Definition at line 49 of file launchConfigureParser.py.

Definition at line 78 of file launchConfigureParser.py.

Definition at line 77 of file launchConfigureParser.py.

string launchConfigureParser.script_nam = "pyscript"

Definition at line 79 of file launchConfigureParser.py.

string launchConfigureParser.sec_tag = "section"

Definition at line 33 of file launchConfigureParser.py.

XML reader for launch configuration file usage.

Definition at line 234 of file launchConfigureParser.py.

string launchConfigureParser.shutdown_servers_nam = "shutdown_servers"

Definition at line 66 of file launchConfigureParser.py.

Definition at line 45 of file launchConfigureParser.py.

list launchConfigureParser.standalone_choices = [ "registry", "study", "moduleCatalog", "cppContainer", "pyContainer"]

Definition at line 83 of file launchConfigureParser.py.

string launchConfigureParser.standalone_nam = "standalone"

Definition at line 53 of file launchConfigureParser.py.

Definition at line 55 of file launchConfigureParser.py.

Definition at line 61 of file launchConfigureParser.py.

Definition at line 39 of file launchConfigureParser.py.

string launchConfigureParser.valgrind_session_nam = "valgrind_session"

Definition at line 65 of file launchConfigureParser.py.

string launchConfigureParser.wake_up_session_nam = "wake_up_session"

Definition at line 68 of file launchConfigureParser.py.

Definition at line 47 of file launchConfigureParser.py.