1 # Copyright (C) 2005 OPEN CASCADE, CEA, EDF R&D, LEG
2 # PRINCIPIA R&D, EADS CCR, Lip6, BV, CEDRAT
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License.
8 # This library is distributed in the hope that it will be useful
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 import os, glob, string, sys, re
25 # names of tags in XML configuration file
30 # names of attributes in XML configuration file
34 # certain values in XML configuration file ("launch" section)
42 portkill_nam = "portkill"
43 killall_nam = "killall"
44 modules_nam = "modules"
45 embedded_nam = "embedded"
46 standalone_nam = "standalone"
48 terminal_nam = "terminal"
50 except_nam = "noexcepthandler"
51 terminal_nam = "terminal"
55 # values in XML configuration file giving specific module parameters (<module_name> section)
56 # which are stored in opts with key <module_name>_<parameter> (eg SMESH_plugins)
57 plugins_nam = "plugins"
59 # values passed as arguments, NOT read from XML config file, but set from within this script
60 appname_nam = "appname"
62 salomeappname = "SalomeApp"
63 script_nam = "pyscript"
65 # possible choices for the "embedded" and "standalone" parameters
66 embedded_choices = [ "registry", "study", "moduleCatalog", "cppContainer", "SalomeAppEngine" ]
67 standalone_choices = [ "registry", "study", "moduleCatalog", "cppContainer", "pyContainer", "supervContainer"]
69 # values of boolean type (must be '0' or '1').
70 # xml_parser.boolValue() is used for correct setting
71 boolKeys = ( gui_nam, splash_nam, logger_nam, file_nam, xterm_nam, portkill_nam, killall_nam, except_nam, pinter_nam )
72 intKeys = ( interp_nam, )
75 listKeys = ( embedded_nam, key_nam, modules_nam, standalone_nam, plugins_nam )
78 # Get the application version
79 # Uses GUI_ROOT_DIR (or KERNEL_ROOT_DIR in batch mode) +/bin/salome/VERSION file
84 root_dir = os.environ.get( 'KERNEL_ROOT_DIR', '' ) # KERNEL_ROOT_DIR or "" if not found
85 if root_dir and os.path.exists( root_dir + "/bin/salome/VERSION" ):
86 filename = root_dir + "/bin/salome/VERSION"
87 root_dir = os.environ.get( 'GUI_ROOT_DIR', '' ) # GUI_ROOT_DIR "" if not found
88 if root_dir and os.path.exists( root_dir + "/bin/salome/VERSION" ):
89 filename = root_dir + "/bin/salome/VERSION"
91 str = open( filename, "r" ).readline() # str = "THIS IS SALOME - SALOMEGUI VERSION: 3.0.0"
92 match = re.search( r':\s+([a-zA-Z0-9.]+)\s*$', str )
94 return match.group( 1 )
100 # Calculate and return configuration file unique ID
101 # For example: for SALOME version 3.1.0a1 the id is 300999701
103 def version_id( fname ):
104 vers = fname.split(".")
107 mr = re.search(r'^([0-9]+)([A-Za-z]?)([0-9]*)',vers[2])
110 release = int(mr.group(1))
112 if len(mr.group(2)): dev1 = ord(mr.group(2))
113 if len(mr.group(3)): dev2 = int(mr.group(3))
114 dev = dev1 * 100 + dev2
118 ver = ver * 100 + minor
119 ver = ver * 100 + release
121 if dev > 0: ver = ver - 10000 + dev
125 # Get user configuration file name
127 def userFile(appname):
130 return "" # not unknown version
131 if sys.platform == "win32":
132 filename = "%s\%s.xml.%s" % (os.environ['HOME'], appname, v)
134 filename = "%s/.%src.%s" % (os.environ['HOME'], appname, v)
135 if os.path.exists(filename):
136 return filename # user preferences file for the current version exists
138 id0 = version_id( v )
139 # get all existing user preferences files
140 if sys.platform == "win32":
141 files = glob.glob( os.environ['HOME'] + "\." + appname + ".xml.*" )
143 files = glob.glob( os.environ['HOME'] + "/." + appname + "rc.*" )
146 match = re.search( r'\.%src\.([a-zA-Z0-9.]+)$'%appname, file )
147 if match: f2v[file] = match.group(1)
151 ver = version_id( f2v[file] )
152 if ver and abs(last_version-id0) > abs(ver-id0):
163 # verbose has already been called
164 if _verbose is not None:
168 from os import getenv
169 _verbose = int(getenv('SALOME_VERBOSE'))
176 def setVerbose(level):
183 def process_containers_params( standalone, embedded ):
184 # 1. filter inappropriate containers names
185 if standalone is not None:
186 standalone = filter( lambda x: x in standalone_choices, standalone )
187 if embedded is not None:
188 embedded = filter( lambda x: x in embedded_choices, embedded )
190 # 2. remove containers appearing in 'standalone' parameter from the 'embedded'
191 # parameter --> i.e. 'standalone' parameter has higher priority
192 if standalone is not None and embedded is not None:
193 embedded = filter( lambda x: x not in standalone, embedded )
195 # 3. return corrected parameters values
196 return standalone, embedded
198 # -----------------------------------------------------------------------------
201 # XML reader for launch configuration file usage
207 def __init__(self, fileName, _opts ):
208 if verbose(): print "Configure parser: processing %s ..." % fileName
211 self.section = section_to_skip
212 parser = xml.sax.make_parser()
213 parser.setContentHandler(self)
214 parser.parse(fileName)
215 standalone, embedded = process_containers_params( self.opts.get( standalone_nam ),
216 self.opts.get( embedded_nam ) )
217 if standalone is not None:
218 self.opts[ standalone_nam ] = standalone
219 if embedded is not None:
220 self.opts[ embedded_nam ] = embedded
223 def boolValue( self, str ):
225 if isinstance(strloc, types.UnicodeType):
226 strloc = strloc.encode().strip()
227 if isinstance(strloc, types.StringType):
228 strlow = strloc.lower()
229 if strlow in ("1", "yes", "y", "on", "true", "ok"):
231 elif strlow in ("0", "no", "n", "off", "false", "cancel"):
236 def intValue( self, str ):
238 if isinstance(strloc, types.UnicodeType):
239 strloc = strloc.encode().strip()
240 if isinstance(strloc, types.StringType):
241 strlow = strloc.lower()
242 if strlow in ("1", "yes", "y", "on", "true", "ok"):
244 elif strlow in ("0", "no", "n", "off", "false", "cancel"):
247 return string.atoi(strloc)
251 def startElement(self, name, attrs):
252 self.space.append(name)
255 # if we are analyzing "section" element and its "name" attribute is
256 # either "launch" or module name -- set section_name
257 if self.space == [doc_tag, sec_tag] and nam_att in attrs.getNames():
258 section_name = attrs.getValue( nam_att )
259 if section_name == lanch_nam:
260 self.section = section_name # launch section
261 elif self.opts.has_key( modules_nam ) and \
262 section_name in self.opts[ modules_nam ]:
263 self.section = section_name # <module> section
265 self.section = section_to_skip # any other section
268 # if we are analyzing "parameter" elements - children of either
269 # "section launch" or "section "<module>"" element, then store them
270 # in self.opts assiciative array (key = [<module>_ + ] value of "name" attribute)
271 elif self.section != section_to_skip and \
272 self.space == [doc_tag, sec_tag, par_tag] and \
273 nam_att in attrs.getNames() and \
274 val_att in attrs.getNames():
275 nam = attrs.getValue( nam_att )
276 val = attrs.getValue( val_att )
277 if self.section == lanch_nam: # key for launch section
279 else: # key for <module> section
280 key = self.section + "_" + nam
282 self.opts[key] = self.boolValue( val ) # assign boolean value: 0 or 1
284 self.opts[key] = self.intValue( val ) # assign integer value
285 elif nam in listKeys:
286 self.opts[key] = filter( lambda a: a.strip(), re.split( "[:;,]", val ) ) # assign list value: []
292 def endElement(self, name):
295 if self.section != section_to_skip and name == sec_tag:
296 self.section = section_to_skip
299 def characters(self, content):
302 def processingInstruction(self, target, data):
305 def setDocumentLocator(self, locator):
308 def startDocument(self):
312 def endDocument(self):
316 # -----------------------------------------------------------------------------
318 booleans = { '1': True , 'yes': True , 'y': True , 'on' : True , 'true' : True , 'ok' : True,
319 '0': False, 'no' : False, 'n': False, 'off': False, 'false': False, 'cancel' : False }
321 boolean_choices = booleans.keys()
323 def check_embedded(option, opt, value, parser):
324 from optparse import OptionValueError
325 assert value is not None
326 if parser.values.embedded:
327 embedded = filter( lambda a: a.strip(), re.split( "[:;,]", parser.values.embedded ) )
330 if parser.values.standalone:
331 standalone = filter( lambda a: a.strip(), re.split( "[:;,]", parser.values.standalone ) )
334 vals = filter( lambda a: a.strip(), re.split( "[:;,]", value ) )
336 if v not in embedded_choices:
337 raise OptionValueError( "option %s: invalid choice: %r (choose from %s)" % ( opt, v, ", ".join( map( repr, embedded_choices ) ) ) )
338 if v not in embedded:
341 del standalone[ standalone.index( v ) ]
343 parser.values.embedded = ",".join( embedded )
344 parser.values.standalone = ",".join( standalone )
347 def check_standalone(option, opt, value, parser):
348 from optparse import OptionValueError
349 assert value is not None
350 if parser.values.embedded:
351 embedded = filter( lambda a: a.strip(), re.split( "[:;,]", parser.values.embedded ) )
354 if parser.values.standalone:
355 standalone = filter( lambda a: a.strip(), re.split( "[:;,]", parser.values.standalone ) )
358 vals = filter( lambda a: a.strip(), re.split( "[:;,]", value ) )
360 if v not in standalone_choices:
361 raise OptionValueError( "option %s: invalid choice: %r (choose from %s)" % ( opt, v, ", ".join( map( repr, standalone_choices ) ) ) )
362 if v not in standalone:
363 standalone.append( v )
365 del embedded[ embedded.index( v ) ]
367 parser.values.embedded = ",".join( embedded )
368 parser.values.standalone = ",".join( standalone )
371 def store_boolean (option, opt, value, parser, *args):
372 if isinstance(value, types.StringType):
374 value_conv = booleans[value.strip().lower()]
375 for attribute in args:
376 setattr(parser.values, attribute, value_conv)
378 raise optparse.OptionValueError(
379 "option %s: invalid boolean value: %s (choose from %s)"
380 % (opt, value, boolean_choices))
382 for attribute in args:
383 setattr(parser.values, attribute, value)
385 def CreateOptionParser (theAdditionalOptions=[]):
386 # GUI/Terminal. Default: GUI
387 help_str = "Launch without GUI (in the terminal mode)."
388 o_t = optparse.Option("-t",
390 action="store_false",
394 help_str = "Launch in Batch Mode. (Without GUI on batch machine)"
395 o_b = optparse.Option("-b",
401 help_str = "Launch in GUI mode [default]."
402 o_g = optparse.Option("-g",
408 # Show Desktop (inly in GUI mode). Default: True
409 help_str = "1 to activate GUI desktop [default], "
410 help_str += "0 to not activate GUI desktop (Session_Server starts, but GUI is not shown). "
411 help_str += "Ignored in the terminal mode."
412 o_d = optparse.Option("-d",
415 #type="choice", choices=boolean_choices,
417 action="callback", callback=store_boolean, callback_args=('desktop',),
420 help_str = "Do not activate GUI desktop (Session_Server starts, but GUI is not shown). "
421 help_str += "The same as --show-desktop=0."
422 o_o = optparse.Option("-o",
424 action="store_false",
428 # Use logger or log-file. Default: nothing.
429 help_str = "Redirect messages to the CORBA collector."
430 #o4 = optparse.Option("-l", "--logger", action="store_true", dest="logger", help=help_str)
431 o_l = optparse.Option("-l",
433 action="store_const", const="CORBA",
436 help_str = "Redirect messages to the <log-file>"
437 o_f = optparse.Option("-f",
439 metavar="<log-file>",
445 # Execute python scripts. Default: None.
446 help_str = "Python script(s) to be imported. Python scripts are imported "
447 help_str += "in the order of their appearance. In GUI mode python scripts "
448 help_str += "are imported in the embedded python interpreter of current study, "
449 help_str += "otherwise in an external python interpreter"
450 o_u = optparse.Option("-u",
452 metavar="<script1,script2,...>",
458 # Configuration XML file. Default: $(HOME)/.SalomeApprc.$(version).
459 help_str = "Parse application settings from the <file> "
460 help_str += "instead of default $(HOME)/.SalomeApprc.$(version)"
461 o_r = optparse.Option("-r",
469 # Use own xterm for each server. Default: False.
470 help_str = "Launch each SALOME server in own xterm console"
471 o_x = optparse.Option("-x",
477 # Modules. Default: Like in configuration files.
478 help_str = "SALOME modules list (where <module1>, <module2> are the names "
479 help_str += "of SALOME modules which should be available in the SALOME session)"
480 o_m = optparse.Option("-m",
482 metavar="<module1,module2,...>",
488 # Embedded servers. Default: Like in configuration files.
489 help_str = "CORBA servers to be launched in the Session embedded mode. "
490 help_str += "Valid values for <serverN>: %s " % ", ".join( embedded_choices )
491 help_str += "[by default the value from the configuration files is used]"
492 o_e = optparse.Option("-e",
494 metavar="<server1,server2,...>",
498 callback=check_embedded,
501 # Standalone servers. Default: Like in configuration files.
502 help_str = "CORBA servers to be launched in the standalone mode (as separate processes). "
503 help_str += "Valid values for <serverN>: %s " % ", ".join( standalone_choices )
504 help_str += "[by default the value from the configuration files is used]"
505 o_s = optparse.Option("-s",
507 metavar="<server1,server2,...>",
511 callback=check_standalone,
514 # Kill with port. Default: False.
515 help_str = "Kill SALOME with the current port"
516 o_p = optparse.Option("-p",
522 # Kill all. Default: False.
523 help_str = "Kill all running SALOME sessions"
524 o_k = optparse.Option("-k",
530 # Additional python interpreters. Default: 0.
531 help_str = "The number of additional external python interpreters to run. "
532 help_str += "Each additional python interpreter is run in separate "
533 help_str += "xterm session with properly set SALOME environment"
534 o_i = optparse.Option("-i",
542 # Splash. Default: True.
543 help_str = "1 to display splash screen [default], "
544 help_str += "0 to disable splash screen. "
545 help_str += "This option is ignored in the terminal mode. "
546 help_str += "It is also ignored if --show-desktop=0 option is used."
547 o_z = optparse.Option("-z",
550 #type="choice", choices=boolean_choices,
552 action="callback", callback=store_boolean, callback_args=('splash',),
556 # Catch exceptions. Default: True.
557 help_str = "1 (yes,true,on,ok) to enable centralized exception handling [default], "
558 help_str += "0 (no,false,off,cancel) to disable centralized exception handling."
559 o_c = optparse.Option("-c",
560 "--catch-exceptions",
562 #type="choice", choices=boolean_choices,
564 action="callback", callback=store_boolean, callback_args=('catch_exceptions',),
565 dest="catch_exceptions",
568 # Print free port and exit
569 help_str = "Print free port and exit"
570 o_a = optparse.Option("--print-port",
572 dest="print_port", default=False,
575 # Do not relink ${HOME}/.omniORB_last.cfg
576 help_str = "Do not save current configuration ${HOME}/.omniORB_last.cfg"
577 o_n = optparse.Option("--nosave-config",
578 action="store_false",
579 dest="save_config", default=True,
582 # Launch with interactive python console. Default: False.
583 help_str = "Launch with interactive python console."
584 o_pi = optparse.Option("--pinter",
589 # Print Naming service port into a user file. Default: False.
590 help_str = "Print Naming Service Port into a user file."
591 o_nspl = optparse.Option("--ns-port-log",
592 metavar="<ns_port_log_file>",
595 dest="ns_port_log_file",
599 opt_list = [o_t,o_g, # GUI/Terminal
602 o_l,o_f, # Use logger or log-file
603 o_u, # Execute python scripts
604 o_r, # Configuration XML file
607 o_e, # Embedded servers
608 o_s, # Standalone servers
609 o_p, # Kill with port
611 o_i, # Additional python interpreters
613 o_c, # Catch exceptions
614 o_a, # Print free port and exit
615 o_n, # --nosave-config
616 o_pi, # Interactive python console
620 #std_options = ["gui", "desktop", "log_file", "py_scripts", "resources",
621 # "xterm", "modules", "embedded", "standalone",
622 # "portkill", "killall", "interp", "splash",
623 # "catch_exceptions", "print_port", "save_config", "ns_port_log_file"]
625 opt_list += theAdditionalOptions
627 a_usage = "%prog [options] [STUDY_FILE]"
628 version_str = "Salome %s" % version()
629 pars = optparse.OptionParser(usage=a_usage, version=version_str, option_list=opt_list)
633 # -----------------------------------------------------------------------------
636 # Get the environment
639 # this attribute is obsolete
643 def get_env(theAdditionalOptions=[], appname="SalomeApp"):
645 # Collect launch configuration files:
646 # - The environment variable "<appname>Config" (SalomeAppConfig) which can
647 # define a list of directories (separated by ':' or ';' symbol) is checked
648 # - If the environment variable "<appname>Config" is not set, only
649 # ${GUI_ROOT_DIR}/share/salome/resources/gui is inspected
650 # - ${GUI_ROOT_DIR}/share/salome/resources/gui directory is always inspected
651 # so it is not necessary to put it in the "<appname>Config" variable
652 # - The directories which are inspected are checked for files "<appname?salomeappname>.xml"
653 # (SalomeApp.xml) which define SALOME configuration
654 # - These directories are analyzed beginning from the last one in the list,
655 # so the first directory listed in "<appname>Config" environment variable
656 # has higher priority: it means that if some configuration options
657 # is found in the next analyzed cofiguration file - it will be replaced
658 # - The last configuration file which is parsed is user configuration file
659 # situated in the home directory: "~/.<appname>rc[.<version>]" (~/SalomeApprc.3.2.0)
661 # - Command line options have the highest priority and replace options
662 # specified in configuration file(s)
666 config_var = appname+'Config'
669 if os.sys.platform == 'win32':
672 # check KERNEL_ROOT_DIR
674 kernel_root_dir=os.environ["KERNEL_ROOT_DIR"]
677 For each SALOME module, the environment variable <moduleN>_ROOT_DIR must be set.
678 KERNEL_ROOT_DIR is mandatory.
683 ############################
684 # parse command line options
685 pars = CreateOptionParser(theAdditionalOptions)
686 (cmd_opts, cmd_args) = pars.parse_args(sys.argv[1:])
687 ############################
689 # Process --print-port option
690 if cmd_opts.print_port:
691 from runSalome import searchFreePort
693 print "port:%s"%(os.environ['NSPORT'])
697 # set resources variable SalomeAppConfig if it is not set yet
699 if os.getenv(config_var):
700 if sys.platform == 'win32':
701 dirs += re.split(';', os.getenv(config_var))
703 dirs += re.split('[;|:]', os.getenv(config_var))
706 if os.getenv("GUI_ROOT_DIR") and os.path.isdir( os.getenv("GUI_ROOT_DIR") + "/share/salome/resources/gui" ):
707 dirs += [os.getenv("GUI_ROOT_DIR") + "/share/salome/resources/gui"]
710 gui_available = False
711 if os.getenv("KERNEL_ROOT_DIR") and os.path.isdir( os.getenv("KERNEL_ROOT_DIR") + "/bin/salome/appliskel" ):
712 dirs += [os.getenv("KERNEL_ROOT_DIR") + "/bin/salome/appliskel"]
714 os.environ[config_var] = separator.join(dirs)
716 dirs.reverse() # reverse order, like in "path" variable - FILO-style processing
719 dirs.remove('') # to remove empty dirs if the variable terminate by ":" or if there are "::" inside
723 _opts = {} # associative array of options to be filled
725 # parse SalomeApp.xml files in directories specified by SalomeAppConfig env variable
727 #filename = dir+'/'+appname+'.xml'
728 filename = dir+'/'+salomeappname+'.xml'
729 if not os.path.exists(filename):
730 print "Configure parser: Warning : could not find configuration file %s" % filename
733 p = xml_parser(filename, _opts)
736 print "Configure parser: Error : can not read configuration file %s" % filename
739 # parse user configuration file
740 # It can be set via --resources=<file> command line option
741 # or is given by default from ${HOME}/.<appname>rc.<version>
742 # If user file for the current version is not found the nearest to it is used
743 user_config = cmd_opts.resources
745 user_config = userFile(appname)
746 if not user_config or not os.path.exists(user_config):
747 print "Configure parser: Warning : could not find user configuration file"
750 p = xml_parser(user_config, _opts)
753 print 'Configure parser: Error : can not read user configuration file'
758 args['user_config'] = user_config
759 #print "User Configuration file: ", args['user_config']
761 # set default values for options which are NOT set in config files
762 for aKey in listKeys:
763 if not args.has_key( aKey ):
766 for aKey in boolKeys:
767 if not args.has_key( aKey ):
772 args[file_nam]=[afile]
774 args[appname_nam] = appname
776 # get the port number
779 file = open(os.environ["OMNIORB_CONFIG"], "r")
782 l = string.split(s, ":")
783 if string.split(l[0], " ")[0] == "ORBInitRef" or string.split(l[0], " ")[0] == "InitRef" :
784 my_port = int(l[len(l)-1])
791 args[port_nam] = my_port
793 ####################################################
794 # apply command-line options to the arguments
795 # each option given in command line overrides the option from xml config file
797 # Options: gui, desktop, log_file, py_scripts, resources,
798 # xterm, modules, embedded, standalone,
799 # portkill, killall, interp, splash,
800 # catch_exceptions, pinter
802 # GUI/Terminal, Desktop, Splash, STUDY_HDF
803 args["session_gui"] = False
804 args[batch_nam] = False
805 args["study_hdf"] = None
806 if cmd_opts.gui is not None:
807 args[gui_nam] = cmd_opts.gui
808 if cmd_opts.batch is not None:
809 args[batch_nam] = True
811 if not gui_available:
812 args[gui_nam] = False
815 args["session_gui"] = True
816 if cmd_opts.desktop is not None:
817 args["session_gui"] = cmd_opts.desktop
818 args[splash_nam] = cmd_opts.desktop
819 if args["session_gui"]:
820 if cmd_opts.splash is not None:
821 args[splash_nam] = cmd_opts.splash
822 if len(cmd_args) > 0:
823 args["study_hdf"] = cmd_args[0]
825 args["session_gui"] = False
826 args[splash_nam] = False
829 if cmd_opts.log_file is not None:
830 if cmd_opts.log_file == 'CORBA':
831 args[logger_nam] = True
833 args[file_nam] = [cmd_opts.log_file]
835 # Naming Service port log file
836 if cmd_opts.ns_port_log_file is not None:
837 args["ns_port_log_file"] = cmd_opts.ns_port_log_file
840 args[script_nam] = []
841 if cmd_opts.py_scripts is not None:
842 listlist = cmd_opts.py_scripts
843 for listi in listlist:
844 args[script_nam] += re.split( "[:;,]", listi)
847 if cmd_opts.xterm is not None: args[xterm_nam] = cmd_opts.xterm
850 if cmd_opts.modules is not None:
851 args[modules_nam] = []
852 listlist = cmd_opts.modules
853 for listi in listlist:
854 args[modules_nam] += re.split( "[:;,]", listi)
856 # if --modules (-m) command line option is not given
857 # try SALOME_MODULES environment variable
858 if os.getenv( "SALOME_MODULES" ):
859 args[modules_nam] = re.split( "[:;,]", os.getenv( "SALOME_MODULES" ) )
863 if cmd_opts.embedded is not None:
864 args[embedded_nam] = filter( lambda a: a.strip(), re.split( "[:;,]", cmd_opts.embedded ) )
867 if cmd_opts.standalone is not None:
868 args[standalone_nam] = filter( lambda a: a.strip(), re.split( "[:;,]", cmd_opts.standalone ) )
870 # Normalize the '--standalone' and '--embedded' parameters
871 standalone, embedded = process_containers_params( args.get( standalone_nam ),
872 args.get( embedded_nam ) )
873 if standalone is not None:
874 args[ standalone_nam ] = standalone
875 if embedded is not None:
876 args[ embedded_nam ] = embedded
879 if cmd_opts.portkill is not None: args[portkill_nam] = cmd_opts.portkill
880 if cmd_opts.killall is not None: args[killall_nam] = cmd_opts.killall
883 if cmd_opts.interp is not None:
884 args[interp_nam] = cmd_opts.interp
887 if cmd_opts.catch_exceptions is not None:
888 args[except_nam] = not cmd_opts.catch_exceptions
891 if cmd_opts.save_config is not None:
892 args['save_config'] = cmd_opts.save_config
894 # Interactive python console
895 if cmd_opts.pinter is not None:
896 args[pinter_nam] = cmd_opts.pinter
898 ####################################################
899 # Add <theAdditionalOptions> values to args
900 for add_opt in theAdditionalOptions:
901 cmd = "args[\"%s\"] = cmd_opts.%s"%(add_opt.dest,add_opt.dest)
903 ####################################################
905 # disable signals handling
906 if args[except_nam] == 1:
907 os.environ["NOT_INTERCEPT_SIGNALS"] = "1"
910 # now modify SalomeAppConfig environment variable
911 # to take into account the SALOME modules
912 if os.sys.platform == 'win32':
913 dirs = re.split('[;]', os.environ[config_var] )
915 dirs = re.split('[;|:]', os.environ[config_var] )
916 for m in args[modules_nam]:
917 if m not in ["KERNEL", "GUI", ""] and os.getenv("%s_ROOT_DIR"%m):
918 d1 = os.getenv("%s_ROOT_DIR"%m) + "/share/salome/resources/" + m.lower()
919 d2 = os.getenv("%s_ROOT_DIR"%m) + "/share/salome/resources"
920 #if os.path.exists( "%s/%s.xml"%(d1, appname) ):
921 if os.path.exists( "%s/%s.xml"%(d1, salomeappname) ):
923 #elif os.path.exists( "%s/%s.xml"%(d2, appname) ):
924 elif os.path.exists( "%s/%s.xml"%(d2, salomeappname) ):
928 os.environ[config_var] = separator.join(dirs)
929 #print "Args: ", args