1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
4 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 import os, glob, string, sys, re
29 # names of tags in XML configuration file
34 # names of attributes in XML configuration file
38 # certain values in XML configuration file ("launch" section)
46 portkill_nam = "portkill"
47 killall_nam = "killall"
48 modules_nam = "modules"
49 embedded_nam = "embedded"
50 standalone_nam = "standalone"
52 terminal_nam = "terminal"
54 except_nam = "noexcepthandler"
55 terminal_nam = "terminal"
60 gdb_session_nam = "gdb_session"
61 ddd_session_nam = "ddd_session"
62 valgrind_session_nam = "valgrind_session"
63 shutdown_servers_nam = "shutdown_servers"
65 # values in XML configuration file giving specific module parameters (<module_name> section)
66 # which are stored in opts with key <module_name>_<parameter> (eg SMESH_plugins)
67 plugins_nam = "plugins"
69 # values passed as arguments, NOT read from XML config file, but set from within this script
70 appname_nam = "appname"
72 salomeappname = "SalomeApp"
73 script_nam = "pyscript"
75 # possible choices for the "embedded" and "standalone" parameters
76 embedded_choices = [ "registry", "study", "moduleCatalog", "cppContainer", "SalomeAppEngine" ]
77 standalone_choices = [ "registry", "study", "moduleCatalog", "cppContainer", "pyContainer"]
79 # values of boolean type (must be '0' or '1').
80 # xml_parser.boolValue() is used for correct setting
81 boolKeys = ( gui_nam, splash_nam, logger_nam, file_nam, xterm_nam, portkill_nam, killall_nam, except_nam, pinter_nam, shutdown_servers_nam )
82 intKeys = ( interp_nam, )
85 listKeys = ( embedded_nam, key_nam, modules_nam, standalone_nam, plugins_nam )
88 # Get the application version
89 # Uses GUI_ROOT_DIR (or KERNEL_ROOT_DIR in batch mode) +/bin/salome/VERSION file
94 root_dir = os.environ.get( 'KERNEL_ROOT_DIR', '' ) # KERNEL_ROOT_DIR or "" if not found
95 if root_dir and os.path.exists( root_dir + "/bin/salome/VERSION" ):
96 filename = root_dir + "/bin/salome/VERSION"
97 root_dir = os.environ.get( 'GUI_ROOT_DIR', '' ) # GUI_ROOT_DIR "" if not found
98 if root_dir and os.path.exists( root_dir + "/bin/salome/VERSION" ):
99 filename = root_dir + "/bin/salome/VERSION"
101 str = open( filename, "r" ).readline() # str = "THIS IS SALOME - SALOMEGUI VERSION: 3.0.0"
102 match = re.search( r':\s+([a-zA-Z0-9.]+)\s*$', str )
104 return match.group( 1 )
110 # Calculate and return configuration file unique ID
111 # For example: for SALOME version 3.1.0a1 the id is 300999701
113 def version_id( fname ):
114 vers = fname.split(".")
117 mr = re.search(r'^([0-9]+)([A-Za-z]?)([0-9]*)',vers[2])
120 release = int(mr.group(1))
122 if len(mr.group(2)): dev1 = ord(mr.group(2))
123 if len(mr.group(3)): dev2 = int(mr.group(3))
124 dev = dev1 * 100 + dev2
128 ver = ver * 100 + minor
129 ver = ver * 100 + release
131 if dev > 0: ver = ver - 10000 + dev
135 # Get user configuration file name
137 def userFile(appname):
140 return "" # not unknown version
141 if sys.platform == "win32":
142 filename = "%s\%s.xml.%s" % (os.environ['HOME'], appname, v)
144 filename = "%s/.%src.%s" % (os.environ['HOME'], appname, v)
145 if os.path.exists(filename):
146 return filename # user preferences file for the current version exists
148 id0 = version_id( v )
149 # get all existing user preferences files
150 if sys.platform == "win32":
151 files = glob.glob( os.environ['HOME'] + "\." + appname + ".xml.*" )
153 files = glob.glob( os.environ['HOME'] + "/." + appname + "rc.*" )
156 match = re.search( r'\.%src\.([a-zA-Z0-9.]+)$'%appname, file )
157 if match: f2v[file] = match.group(1)
161 ver = version_id( f2v[file] )
162 if ver and abs(last_version-id0) > abs(ver-id0):
173 # verbose has already been called
174 if _verbose is not None:
178 from os import getenv
179 _verbose = int(getenv('SALOME_VERBOSE'))
186 def setVerbose(level):
193 def process_containers_params( standalone, embedded ):
194 # 1. filter inappropriate containers names
195 if standalone is not None:
196 standalone = filter( lambda x: x in standalone_choices, standalone )
197 if embedded is not None:
198 embedded = filter( lambda x: x in embedded_choices, embedded )
200 # 2. remove containers appearing in 'standalone' parameter from the 'embedded'
201 # parameter --> i.e. 'standalone' parameter has higher priority
202 if standalone is not None and embedded is not None:
203 embedded = filter( lambda x: x not in standalone, embedded )
205 # 3. return corrected parameters values
206 return standalone, embedded
208 # -----------------------------------------------------------------------------
211 # XML reader for launch configuration file usage
217 def __init__(self, fileName, _opts ):
218 if verbose(): print "Configure parser: processing %s ..." % fileName
221 self.section = section_to_skip
222 parser = xml.sax.make_parser()
223 parser.setContentHandler(self)
224 parser.parse(fileName)
225 standalone, embedded = process_containers_params( self.opts.get( standalone_nam ),
226 self.opts.get( embedded_nam ) )
227 if standalone is not None:
228 self.opts[ standalone_nam ] = standalone
229 if embedded is not None:
230 self.opts[ embedded_nam ] = embedded
233 def boolValue( self, str ):
235 if isinstance(strloc, types.UnicodeType):
236 strloc = strloc.encode().strip()
237 if isinstance(strloc, types.StringType):
238 strlow = strloc.lower()
239 if strlow in ("1", "yes", "y", "on", "true", "ok"):
241 elif strlow in ("0", "no", "n", "off", "false", "cancel"):
246 def intValue( self, str ):
248 if isinstance(strloc, types.UnicodeType):
249 strloc = strloc.encode().strip()
250 if isinstance(strloc, types.StringType):
251 strlow = strloc.lower()
252 if strlow in ("1", "yes", "y", "on", "true", "ok"):
254 elif strlow in ("0", "no", "n", "off", "false", "cancel"):
257 return string.atoi(strloc)
261 def startElement(self, name, attrs):
262 self.space.append(name)
265 # if we are analyzing "section" element and its "name" attribute is
266 # either "launch" or module name -- set section_name
267 if self.space == [doc_tag, sec_tag] and nam_att in attrs.getNames():
268 section_name = attrs.getValue( nam_att )
269 if section_name == lanch_nam:
270 self.section = section_name # launch section
271 elif self.opts.has_key( modules_nam ) and \
272 section_name in self.opts[ modules_nam ]:
273 self.section = section_name # <module> section
275 self.section = section_to_skip # any other section
278 # if we are analyzing "parameter" elements - children of either
279 # "section launch" or "section "<module>"" element, then store them
280 # in self.opts assiciative array (key = [<module>_ + ] value of "name" attribute)
281 elif self.section != section_to_skip and \
282 self.space == [doc_tag, sec_tag, par_tag] and \
283 nam_att in attrs.getNames() and \
284 val_att in attrs.getNames():
285 nam = attrs.getValue( nam_att )
286 val = attrs.getValue( val_att )
287 if self.section == lanch_nam: # key for launch section
289 else: # key for <module> section
290 key = self.section + "_" + nam
292 self.opts[key] = self.boolValue( val ) # assign boolean value: 0 or 1
294 self.opts[key] = self.intValue( val ) # assign integer value
295 elif nam in listKeys:
296 self.opts[key] = filter( lambda a: a.strip(), re.split( "[:;,]", val ) ) # assign list value: []
302 def endElement(self, name):
305 if self.section != section_to_skip and name == sec_tag:
306 self.section = section_to_skip
309 def characters(self, content):
312 def processingInstruction(self, target, data):
315 def setDocumentLocator(self, locator):
318 def startDocument(self):
322 def endDocument(self):
326 # -----------------------------------------------------------------------------
328 booleans = { '1': True , 'yes': True , 'y': True , 'on' : True , 'true' : True , 'ok' : True,
329 '0': False, 'no' : False, 'n': False, 'off': False, 'false': False, 'cancel' : False }
331 boolean_choices = booleans.keys()
333 def check_embedded(option, opt, value, parser):
334 from optparse import OptionValueError
335 assert value is not None
336 if parser.values.embedded:
337 embedded = filter( lambda a: a.strip(), re.split( "[:;,]", parser.values.embedded ) )
340 if parser.values.standalone:
341 standalone = filter( lambda a: a.strip(), re.split( "[:;,]", parser.values.standalone ) )
344 vals = filter( lambda a: a.strip(), re.split( "[:;,]", value ) )
346 if v not in embedded_choices:
347 raise OptionValueError( "option %s: invalid choice: %r (choose from %s)" % ( opt, v, ", ".join( map( repr, embedded_choices ) ) ) )
348 if v not in embedded:
351 del standalone[ standalone.index( v ) ]
353 parser.values.embedded = ",".join( embedded )
354 parser.values.standalone = ",".join( standalone )
357 def check_standalone(option, opt, value, parser):
358 from optparse import OptionValueError
359 assert value is not None
360 if parser.values.embedded:
361 embedded = filter( lambda a: a.strip(), re.split( "[:;,]", parser.values.embedded ) )
364 if parser.values.standalone:
365 standalone = filter( lambda a: a.strip(), re.split( "[:;,]", parser.values.standalone ) )
368 vals = filter( lambda a: a.strip(), re.split( "[:;,]", value ) )
370 if v not in standalone_choices:
371 raise OptionValueError( "option %s: invalid choice: %r (choose from %s)" % ( opt, v, ", ".join( map( repr, standalone_choices ) ) ) )
372 if v not in standalone:
373 standalone.append( v )
375 del embedded[ embedded.index( v ) ]
377 parser.values.embedded = ",".join( embedded )
378 parser.values.standalone = ",".join( standalone )
381 def store_boolean (option, opt, value, parser, *args):
382 if isinstance(value, types.StringType):
384 value_conv = booleans[value.strip().lower()]
385 for attribute in args:
386 setattr(parser.values, attribute, value_conv)
388 raise optparse.OptionValueError(
389 "option %s: invalid boolean value: %s (choose from %s)"
390 % (opt, value, boolean_choices))
392 for attribute in args:
393 setattr(parser.values, attribute, value)
395 def CreateOptionParser (theAdditionalOptions=[]):
396 # GUI/Terminal. Default: GUI
397 help_str = "Launch without GUI (in the terminal mode)."
398 o_t = optparse.Option("-t",
400 action="store_false",
404 help_str = "Launch in Batch Mode. (Without GUI on batch machine)"
405 o_b = optparse.Option("-b",
411 help_str = "Launch in GUI mode [default]."
412 o_g = optparse.Option("-g",
418 # Show Desktop (inly in GUI mode). Default: True
419 help_str = "1 to activate GUI desktop [default], "
420 help_str += "0 to not activate GUI desktop (Session_Server starts, but GUI is not shown). "
421 help_str += "Ignored in the terminal mode."
422 o_d = optparse.Option("-d",
425 #type="choice", choices=boolean_choices,
427 action="callback", callback=store_boolean, callback_args=('desktop',),
430 help_str = "Do not activate GUI desktop (Session_Server starts, but GUI is not shown). "
431 help_str += "The same as --show-desktop=0."
432 o_o = optparse.Option("-o",
434 action="store_false",
438 # Use logger or log-file. Default: nothing.
439 help_str = "Redirect messages to the CORBA collector."
440 #o4 = optparse.Option("-l", "--logger", action="store_true", dest="logger", help=help_str)
441 o_l = optparse.Option("-l",
443 action="store_const", const="CORBA",
446 help_str = "Redirect messages to the <log-file>"
447 o_f = optparse.Option("-f",
449 metavar="<log-file>",
455 # Execute python scripts. Default: None.
456 help_str = "Python script(s) to be imported. Python scripts are imported "
457 help_str += "in the order of their appearance. In GUI mode python scripts "
458 help_str += "are imported in the embedded python interpreter of current study, "
459 help_str += "otherwise in an external python interpreter. "
460 help_str += "Note: this option is obsolete. Instead you can pass Python script(s) "
461 help_str += "directly as positional parameter."
462 o_u = optparse.Option("-u",
464 metavar="<script1,script2,...>",
470 # Configuration XML file. Default: $(HOME)/.SalomeApprc.$(version).
471 help_str = "Parse application settings from the <file> "
472 help_str += "instead of default $(HOME)/.SalomeApprc.$(version)"
473 o_r = optparse.Option("-r",
481 # Use own xterm for each server. Default: False.
482 help_str = "Launch each SALOME server in own xterm console"
483 o_x = optparse.Option("-x",
489 # Modules. Default: Like in configuration files.
490 help_str = "SALOME modules list (where <module1>, <module2> are the names "
491 help_str += "of SALOME modules which should be available in the SALOME session)"
492 o_m = optparse.Option("-m",
494 metavar="<module1,module2,...>",
500 # Embedded servers. Default: Like in configuration files.
501 help_str = "CORBA servers to be launched in the Session embedded mode. "
502 help_str += "Valid values for <serverN>: %s " % ", ".join( embedded_choices )
503 help_str += "[by default the value from the configuration files is used]"
504 o_e = optparse.Option("-e",
506 metavar="<server1,server2,...>",
510 callback=check_embedded,
513 # Standalone servers. Default: Like in configuration files.
514 help_str = "CORBA servers to be launched in the standalone mode (as separate processes). "
515 help_str += "Valid values for <serverN>: %s " % ", ".join( standalone_choices )
516 help_str += "[by default the value from the configuration files is used]"
517 o_s = optparse.Option("-s",
519 metavar="<server1,server2,...>",
523 callback=check_standalone,
526 # Kill with port. Default: False.
527 help_str = "Kill SALOME with the current port"
528 o_p = optparse.Option("-p",
534 # Kill all. Default: False.
535 help_str = "Kill all running SALOME sessions"
536 o_k = optparse.Option("-k",
542 # Additional python interpreters. Default: 0.
543 help_str = "The number of additional external python interpreters to run. "
544 help_str += "Each additional python interpreter is run in separate "
545 help_str += "xterm session with properly set SALOME environment"
546 o_i = optparse.Option("-i",
554 # Splash. Default: True.
555 help_str = "1 to display splash screen [default], "
556 help_str += "0 to disable splash screen. "
557 help_str += "This option is ignored in the terminal mode. "
558 help_str += "It is also ignored if --show-desktop=0 option is used."
559 o_z = optparse.Option("-z",
562 #type="choice", choices=boolean_choices,
564 action="callback", callback=store_boolean, callback_args=('splash',),
568 # Catch exceptions. Default: True.
569 help_str = "1 (yes,true,on,ok) to enable centralized exception handling [default], "
570 help_str += "0 (no,false,off,cancel) to disable centralized exception handling."
571 o_c = optparse.Option("-c",
572 "--catch-exceptions",
574 #type="choice", choices=boolean_choices,
576 action="callback", callback=store_boolean, callback_args=('catch_exceptions',),
577 dest="catch_exceptions",
580 # Print free port and exit
581 help_str = "Print free port and exit"
582 o_a = optparse.Option("--print-port",
584 dest="print_port", default=False,
587 # Do not relink ${HOME}/.omniORB_last.cfg
588 help_str = "Do not save current configuration ${HOME}/.omniORB_last.cfg"
589 o_n = optparse.Option("--nosave-config",
590 action="store_false",
591 dest="save_config", default=True,
594 # Launch with interactive python console. Default: False.
595 help_str = "Launch with interactive python console."
596 o_pi = optparse.Option("--pinter",
601 # Print Naming service port into a user file. Default: False.
602 help_str = "Print Naming Service Port into a user file."
603 o_nspl = optparse.Option("--ns-port-log",
604 metavar="<ns_port_log_file>",
607 dest="ns_port_log_file",
610 # Write/read test script file with help of TestRecorder. Default: False.
611 help_str = "Write/read test script file with help of TestRecorder."
612 o_test = optparse.Option("--test",
613 metavar="<test_script_file>",
616 dest="test_script_file",
619 # Reproducing test script with help of TestRecorder. Default: False.
620 help_str = "Reproducing test script with help of TestRecorder."
621 o_play = optparse.Option("--play",
622 metavar="<play_script_file>",
625 dest="play_script_file",
629 help_str = "Launch session with gdb"
630 o_gdb = optparse.Option("--gdb-session",
632 dest="gdb_session", default=False,
636 help_str = "Launch session with ddd"
637 o_ddd = optparse.Option("--ddd-session",
639 dest="ddd_session", default=False,
644 help_str = "Launch session with valgrind $VALGRIND_OPTIONS"
645 o_valgrind = optparse.Option("--valgrind-session",
647 dest="valgrind_session", default=False,
650 # shutdown-servers. Default: False.
651 help_str = "1 to shutdown standalone servers when leaving python interpreter, "
652 help_str += "0 to keep the standalone servers as daemon [default]. "
653 help_str += "This option is only useful in batchmode "
654 help_str += "(terminal mode or without showing desktop)."
655 o_shutdown = optparse.Option("--shutdown-servers",
657 #type="choice", choices=boolean_choices,
659 action="callback", callback=store_boolean, callback_args=('shutdown_servers',),
660 dest="shutdown_servers",
664 opt_list = [o_t,o_g, # GUI/Terminal
667 o_l,o_f, # Use logger or log-file
668 o_u, # Execute python scripts
669 o_r, # Configuration XML file
672 o_e, # Embedded servers
673 o_s, # Standalone servers
674 o_p, # Kill with port
676 o_i, # Additional python interpreters
678 o_c, # Catch exceptions
679 o_a, # Print free port and exit
680 o_n, # --nosave-config
681 o_pi, # Interactive python console
683 o_test, # Write/read test script file with help of TestRecorder
684 o_play, # Reproducing test script with help of TestRecorder
691 #std_options = ["gui", "desktop", "log_file", "py_scripts", "resources",
692 # "xterm", "modules", "embedded", "standalone",
693 # "portkill", "killall", "interp", "splash",
694 # "catch_exceptions", "print_port", "save_config", "ns_port_log_file"]
696 opt_list += theAdditionalOptions
698 a_usage = "%prog [options] [STUDY_FILE] [PYTHON_FILE [PYTHON_FILE ...]]"
699 version_str = "Salome %s" % version()
700 pars = optparse.OptionParser(usage=a_usage, version=version_str, option_list=opt_list)
704 # -----------------------------------------------------------------------------
707 # Get the environment
710 # this attribute is obsolete
714 def get_env(theAdditionalOptions=[], appname="SalomeApp"):
716 # Collect launch configuration files:
717 # - The environment variable "<appname>Config" (SalomeAppConfig) which can
718 # define a list of directories (separated by ':' or ';' symbol) is checked
719 # - If the environment variable "<appname>Config" is not set, only
720 # ${GUI_ROOT_DIR}/share/salome/resources/gui is inspected
721 # - ${GUI_ROOT_DIR}/share/salome/resources/gui directory is always inspected
722 # so it is not necessary to put it in the "<appname>Config" variable
723 # - The directories which are inspected are checked for files "<appname?salomeappname>.xml"
724 # (SalomeApp.xml) which define SALOME configuration
725 # - These directories are analyzed beginning from the last one in the list,
726 # so the first directory listed in "<appname>Config" environment variable
727 # has higher priority: it means that if some configuration options
728 # is found in the next analyzed cofiguration file - it will be replaced
729 # - The last configuration file which is parsed is user configuration file
730 # situated in the home directory: "~/.<appname>rc[.<version>]" (~/SalomeApprc.3.2.0)
732 # - Command line options have the highest priority and replace options
733 # specified in configuration file(s)
737 config_var = appname+'Config'
740 if os.sys.platform == 'win32':
743 # check KERNEL_ROOT_DIR
745 kernel_root_dir=os.environ["KERNEL_ROOT_DIR"]
748 For each SALOME module, the environment variable <moduleN>_ROOT_DIR must be set.
749 KERNEL_ROOT_DIR is mandatory.
754 ############################
755 # parse command line options
756 pars = CreateOptionParser(theAdditionalOptions)
757 (cmd_opts, cmd_args) = pars.parse_args(sys.argv[1:])
758 ############################
760 # Process --print-port option
761 if cmd_opts.print_port:
762 from runSalome import searchFreePort
764 print "port:%s"%(os.environ['NSPORT'])
768 # set resources variable SalomeAppConfig if it is not set yet
770 if os.getenv(config_var):
771 if sys.platform == 'win32':
772 dirs += re.split(';', os.getenv(config_var))
774 dirs += re.split('[;|:]', os.getenv(config_var))
777 if os.getenv("GUI_ROOT_DIR") and os.path.isdir( os.getenv("GUI_ROOT_DIR") + "/share/salome/resources/gui" ):
778 dirs += [os.getenv("GUI_ROOT_DIR") + "/share/salome/resources/gui"]
781 gui_available = False
782 if os.getenv("KERNEL_ROOT_DIR") and os.path.isdir( os.getenv("KERNEL_ROOT_DIR") + "/bin/salome/appliskel" ):
783 dirs += [os.getenv("KERNEL_ROOT_DIR") + "/bin/salome/appliskel"]
785 os.environ[config_var] = separator.join(dirs)
787 dirs.reverse() # reverse order, like in "path" variable - FILO-style processing
790 dirs.remove('') # to remove empty dirs if the variable terminate by ":" or if there are "::" inside
794 _opts = {} # associative array of options to be filled
796 # parse SalomeApp.xml files in directories specified by SalomeAppConfig env variable
798 #filename = dir+'/'+appname+'.xml'
799 filename = dir+'/'+salomeappname+'.xml'
800 if not os.path.exists(filename):
801 print "Configure parser: Warning : could not find configuration file %s" % filename
804 p = xml_parser(filename, _opts)
807 print "Configure parser: Error : can not read configuration file %s" % filename
810 # parse user configuration file
811 # It can be set via --resources=<file> command line option
812 # or is given by default from ${HOME}/.<appname>rc.<version>
813 # If user file for the current version is not found the nearest to it is used
814 user_config = cmd_opts.resources
816 user_config = userFile(appname)
817 if not user_config or not os.path.exists(user_config):
818 print "Configure parser: Warning : could not find user configuration file"
821 p = xml_parser(user_config, _opts)
824 print 'Configure parser: Error : can not read user configuration file'
829 args['user_config'] = user_config
830 #print "User Configuration file: ", args['user_config']
832 # set default values for options which are NOT set in config files
833 for aKey in listKeys:
834 if not args.has_key( aKey ):
837 for aKey in boolKeys:
838 if not args.has_key( aKey ):
843 args[file_nam]=[afile]
845 args[appname_nam] = appname
847 # get the port number
850 file = open(os.environ["OMNIORB_CONFIG"], "r")
853 l = string.split(s, ":")
854 if string.split(l[0], " ")[0] == "ORBInitRef" or string.split(l[0], " ")[0] == "InitRef" :
855 my_port = int(l[len(l)-1])
862 args[port_nam] = my_port
864 ####################################################
865 # apply command-line options to the arguments
866 # each option given in command line overrides the option from xml config file
868 # Options: gui, desktop, log_file, py_scripts, resources,
869 # xterm, modules, embedded, standalone,
870 # portkill, killall, interp, splash,
871 # catch_exceptions, pinter
873 # GUI/Terminal, Desktop, Splash, STUDY_HDF
874 args["session_gui"] = False
875 args[batch_nam] = False
876 args["study_hdf"] = None
877 if cmd_opts.gui is not None:
878 args[gui_nam] = cmd_opts.gui
879 if cmd_opts.batch is not None:
880 args[batch_nam] = True
882 if not gui_available:
883 args[gui_nam] = False
886 args["session_gui"] = True
887 if cmd_opts.desktop is not None:
888 args["session_gui"] = cmd_opts.desktop
889 args[splash_nam] = cmd_opts.desktop
890 if args["session_gui"]:
891 if cmd_opts.splash is not None:
892 args[splash_nam] = cmd_opts.splash
894 args["session_gui"] = False
895 args[splash_nam] = False
898 if cmd_opts.log_file is not None:
899 if cmd_opts.log_file == 'CORBA':
900 args[logger_nam] = True
902 args[file_nam] = [cmd_opts.log_file]
904 # Naming Service port log file
905 if cmd_opts.ns_port_log_file is not None:
906 args["ns_port_log_file"] = cmd_opts.ns_port_log_file
909 args[script_nam] = []
910 if cmd_opts.py_scripts is not None:
911 listlist = cmd_opts.py_scripts
912 for listi in listlist:
913 if os.sys.platform == 'win32':
914 args[script_nam] += re.split( "[;,]", listi)
916 args[script_nam] += re.split( "[:;,]", listi)
918 if arg[-3:] == ".py":
919 args[script_nam].append(arg)
920 elif not args["study_hdf"]:
921 args["study_hdf"] = arg
926 if cmd_opts.xterm is not None: args[xterm_nam] = cmd_opts.xterm
929 if cmd_opts.modules is not None:
930 args[modules_nam] = []
931 listlist = cmd_opts.modules
932 for listi in listlist:
933 args[modules_nam] += re.split( "[:;,]", listi)
935 # if --modules (-m) command line option is not given
936 # try SALOME_MODULES environment variable
937 if os.getenv( "SALOME_MODULES" ):
938 args[modules_nam] = re.split( "[:;,]", os.getenv( "SALOME_MODULES" ) )
942 if cmd_opts.embedded is not None:
943 args[embedded_nam] = filter( lambda a: a.strip(), re.split( "[:;,]", cmd_opts.embedded ) )
946 if cmd_opts.standalone is not None:
947 args[standalone_nam] = filter( lambda a: a.strip(), re.split( "[:;,]", cmd_opts.standalone ) )
949 # Normalize the '--standalone' and '--embedded' parameters
950 standalone, embedded = process_containers_params( args.get( standalone_nam ),
951 args.get( embedded_nam ) )
952 if standalone is not None:
953 args[ standalone_nam ] = standalone
954 if embedded is not None:
955 args[ embedded_nam ] = embedded
958 if cmd_opts.portkill is not None: args[portkill_nam] = cmd_opts.portkill
959 if cmd_opts.killall is not None: args[killall_nam] = cmd_opts.killall
962 if cmd_opts.interp is not None:
963 args[interp_nam] = cmd_opts.interp
966 if cmd_opts.catch_exceptions is not None:
967 args[except_nam] = not cmd_opts.catch_exceptions
970 if cmd_opts.save_config is not None:
971 args['save_config'] = cmd_opts.save_config
973 # Interactive python console
974 if cmd_opts.pinter is not None:
975 args[pinter_nam] = cmd_opts.pinter
977 # Gdb session in xterm
978 if cmd_opts.gdb_session is not None:
979 args[gdb_session_nam] = cmd_opts.gdb_session
981 # Ddd session in xterm
982 if cmd_opts.ddd_session is not None:
983 args[ddd_session_nam] = cmd_opts.ddd_session
986 if cmd_opts.valgrind_session is not None:
987 args[valgrind_session_nam] = cmd_opts.valgrind_session
990 if cmd_opts.shutdown_servers is None:
991 args[shutdown_servers_nam] = 0
993 args[shutdown_servers_nam] = cmd_opts.shutdown_servers
996 ####################################################
997 # Add <theAdditionalOptions> values to args
998 for add_opt in theAdditionalOptions:
999 cmd = "args[\"%s\"] = cmd_opts.%s"%(add_opt.dest,add_opt.dest)
1001 ####################################################
1003 # disable signals handling
1004 if args[except_nam] == 1:
1005 os.environ["NOT_INTERCEPT_SIGNALS"] = "1"
1008 # now modify SalomeAppConfig environment variable
1009 # to take into account the SALOME modules
1010 if os.sys.platform == 'win32':
1011 dirs = re.split('[;]', os.environ[config_var] )
1013 dirs = re.split('[;|:]', os.environ[config_var] )
1014 for m in args[modules_nam]:
1015 if m not in ["KERNEL", "GUI", ""] and os.getenv("%s_ROOT_DIR"%m):
1016 d1 = os.getenv("%s_ROOT_DIR"%m) + "/share/salome/resources/" + m.lower()
1017 d2 = os.getenv("%s_ROOT_DIR"%m) + "/share/salome/resources"
1018 #if os.path.exists( "%s/%s.xml"%(d1, appname) ):
1019 if os.path.exists( "%s/%s.xml"%(d1, salomeappname) ):
1021 #elif os.path.exists( "%s/%s.xml"%(d2, appname) ):
1022 elif os.path.exists( "%s/%s.xml"%(d2, salomeappname) ):
1026 if cmd_opts.test_script_file is not None:
1028 filename = cmd_opts.test_script_file
1029 args[test_nam] += re.split( "[:;,]", filename )
1032 if cmd_opts.play_script_file is not None:
1034 filename = cmd_opts.play_script_file
1035 args[play_nam] += re.split( "[:;,]", filename )
1038 os.environ[config_var] = separator.join(dirs)
1039 #print "Args: ", args