Lines 16-21
Link Here
|
16 |
# |
16 |
# |
17 |
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com |
17 |
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com |
18 |
# |
18 |
# |
|
|
19 |
|
19 |
import os, glob, string, sys, re |
20 |
import os, glob, string, sys, re |
20 |
import xml.sax |
21 |
import xml.sax |
21 |
|
22 |
|
Lines 30-35
Link Here
|
30 |
|
31 |
|
31 |
# certain values in XML configuration file ("launch" section) |
32 |
# certain values in XML configuration file ("launch" section) |
32 |
lanch_nam = "launch" |
33 |
lanch_nam = "launch" |
|
|
34 |
help_nam = "help" |
33 |
gui_nam = "gui" |
35 |
gui_nam = "gui" |
34 |
splash_nam = "splash" |
36 |
splash_nam = "splash" |
35 |
logger_nam = "logger" |
37 |
logger_nam = "logger" |
Lines 44-49
Link Here
|
44 |
key_nam = "key" |
46 |
key_nam = "key" |
45 |
interp_nam = "interp" |
47 |
interp_nam = "interp" |
46 |
except_nam = "noexcepthandler" |
48 |
except_nam = "noexcepthandler" |
|
|
49 |
terminal_nam = "terminal" |
50 |
case_nam = "test" |
47 |
|
51 |
|
48 |
# values in XML configuration file giving specific module parameters (<module_name> section) |
52 |
# values in XML configuration file giving specific module parameters (<module_name> section) |
49 |
# which are stored in opts with key <module_name>_<parameter> (eg SMESH_plugins) |
53 |
# which are stored in opts with key <module_name>_<parameter> (eg SMESH_plugins) |
Lines 62-80
Link Here
|
62 |
# values of list type |
66 |
# values of list type |
63 |
listKeys = ( containers_nam, embedded_nam, key_nam, modules_nam, standalone_nam, plugins_nam ) |
67 |
listKeys = ( containers_nam, embedded_nam, key_nam, modules_nam, standalone_nam, plugins_nam ) |
64 |
|
68 |
|
65 |
# return application version (uses GUI_ROOT_DIR (or KERNEL_ROOT_DIR in batch mode) +/bin/salome/VERSION) |
69 |
### |
|
|
70 |
# Get the application version |
71 |
# Uses GUI_ROOT_DIR (or KERNEL_ROOT_DIR in batch mode) +/bin/salome/VERSION file |
72 |
### |
66 |
def version(): |
73 |
def version(): |
67 |
root_dir = os.environ.get( 'KERNEL_ROOT_DIR', '' ) # KERNEL_ROOT_DIR or "" if not found |
74 |
try: |
68 |
root_dir = os.environ.get( 'GUI_ROOT_DIR', root_dir ) # GUI_ROOT_DIR or KERNEL_ROOT_DIR or "" if both not found |
75 |
filename = None |
69 |
filename = root_dir+'/bin/salome/VERSION' |
76 |
root_dir = os.environ.get( 'KERNEL_ROOT_DIR', '' ) # KERNEL_ROOT_DIR or "" if not found |
70 |
str = open( filename, "r" ).readline() # str = "THIS IS SALOME - SALOMEGUI VERSION: 3.0.0" |
77 |
if root_dir and os.path.exists( root_dir + "/bin/salome/VERSION" ): |
71 |
match = re.search( r':\s+([a-zA-Z0-9.]+)\s*$', str ) |
78 |
filename = root_dir + "/bin/salome/VERSION" |
72 |
if match : |
79 |
root_dir = os.environ.get( 'GUI_ROOT_DIR', '' ) # GUI_ROOT_DIR "" if not found |
73 |
return match.group( 1 ) |
80 |
if root_dir and os.path.exists( root_dir + "/bin/salome/VERSION" ): |
|
|
81 |
filename = root_dir + "/bin/salome/VERSION" |
82 |
if filename: |
83 |
str = open( filename, "r" ).readline() # str = "THIS IS SALOME - SALOMEGUI VERSION: 3.0.0" |
84 |
match = re.search( r':\s+([a-zA-Z0-9.]+)\s*$', str ) |
85 |
if match : |
86 |
return match.group( 1 ) |
87 |
except: |
88 |
pass |
74 |
return '' |
89 |
return '' |
75 |
|
90 |
|
76 |
# calculate and return configuration file id in order to unically identify it |
91 |
### |
77 |
# for example: for 3.1.0a1 the id is 301000101 |
92 |
# Calculate and return configuration file unique ID |
|
|
93 |
# For example: for SALOME version 3.1.0a1 the id is 300999701 |
94 |
### |
78 |
def version_id( fname ): |
95 |
def version_id( fname ): |
79 |
vers = fname.split(".") |
96 |
vers = fname.split(".") |
80 |
major = int(vers[0]) |
97 |
major = int(vers[0]) |
Lines 96-102
Link Here
|
96 |
if dev > 0: ver = ver - 10000 + dev |
113 |
if dev > 0: ver = ver - 10000 + dev |
97 |
return ver |
114 |
return ver |
98 |
|
115 |
|
99 |
# get user configuration file name |
116 |
### |
|
|
117 |
# Get user configuration file name |
118 |
### |
100 |
def userFile(): |
119 |
def userFile(): |
101 |
v = version() |
120 |
v = version() |
102 |
if not v: |
121 |
if not v: |
Lines 123-129
Link Here
|
123 |
|
142 |
|
124 |
# ----------------------------------------------------------------------------- |
143 |
# ----------------------------------------------------------------------------- |
125 |
|
144 |
|
126 |
### xml reader for launch configuration file usage |
145 |
### |
|
|
146 |
# XML reader for launch configuration file usage |
147 |
### |
127 |
|
148 |
|
128 |
section_to_skip = "" |
149 |
section_to_skip = "" |
129 |
|
150 |
|
Lines 212-307
Link Here
|
212 |
|
233 |
|
213 |
# ----------------------------------------------------------------------------- |
234 |
# ----------------------------------------------------------------------------- |
214 |
|
235 |
|
215 |
### searching for launch configuration files |
236 |
### |
216 |
# the rule: |
237 |
# Command line options parser |
217 |
# - environment variable {'appname'+'Config'} (SalomeAppConfig) contains list of directories (';' as devider) |
238 |
### |
218 |
# - these directories contain 'appname'+'.xml' (SalomeApp.xml) configuration files |
|
|
219 |
# - these files are analyzed beginning with the last one (last directory in the list) |
220 |
# - if a key is found in next analyzed cofiguration file - it will be replaced |
221 |
# - the last configuration file to be analyzed - ~/.'appname'+'rc' (~/SalomeApprc) (if it exists) |
222 |
# - but anyway, if user specifies a certain option in a command line - it will replace the values |
223 |
# - specified in configuration file(s) |
224 |
# - once again the order of settings (next setting replaces the previous ones): |
225 |
# - SalomeApp.xml files in directories specified by SalomeAppConfig env variable |
226 |
# - .SalomeApprc file in user's catalogue |
227 |
# - command line |
228 |
|
229 |
config_var = appname+'Config' |
230 |
# set resources variables if not yet set |
231 |
dirs = [] |
232 |
if os.getenv(config_var): |
233 |
dirs += re.split('[;|:]', os.getenv(config_var)) |
234 |
if os.getenv("GUI_ROOT_DIR"): |
235 |
dirs += [os.getenv("GUI_ROOT_DIR") + "/share/salome/resources/gui"] |
236 |
os.environ[config_var] = ":".join(dirs) |
237 |
|
238 |
dirs.reverse() # reverse order, like in "path" variable - FILO-style processing |
239 |
|
240 |
_opts = {} # assiciative array of options to be filled |
241 |
|
242 |
# SalomeApp.xml files in directories specified by SalomeAppConfig env variable |
243 |
for dir in dirs: |
244 |
filename = dir+'/'+appname+'.xml' |
245 |
if not os.path.exists(filename): |
246 |
print "Configure parser: Warning : could not find configuration file %s" % filename |
247 |
else: |
248 |
try: |
249 |
p = xml_parser(filename, _opts) |
250 |
_opts = p.opts |
251 |
except: |
252 |
print "Configure parser: Error : can not read configuration file %s" % filename |
253 |
pass |
254 |
|
255 |
# SalomeApprc file in user's catalogue |
256 |
filename = userFile() |
257 |
if not filename or not os.path.exists(filename): |
258 |
print "Configure parser: Warning : could not find user configuration file" |
259 |
else: |
260 |
try: |
261 |
p = xml_parser(filename, _opts) |
262 |
_opts = p.opts |
263 |
except: |
264 |
print 'Configure parser: Error : can not read user configuration file' |
265 |
|
266 |
args = _opts |
267 |
|
268 |
# --- setting default values of keys if they were NOT set in config files --- |
269 |
for aKey in listKeys: |
270 |
if not args.has_key( aKey ): |
271 |
args[aKey]=[] |
272 |
|
273 |
for aKey in boolKeys: |
274 |
if not args.has_key( aKey ): |
275 |
args[aKey]=0 |
276 |
|
277 |
if args[file_nam]: |
278 |
afile=args[file_nam] |
279 |
args[file_nam]=[afile] |
280 |
|
281 |
args[appname_nam] = appname |
282 |
|
283 |
### searching for my port |
284 |
|
285 |
my_port = 2809 |
286 |
try: |
287 |
file = open(os.environ["OMNIORB_CONFIG"], "r") |
288 |
s = file.read() |
289 |
while len(s): |
290 |
l = string.split(s, ":") |
291 |
if string.split(l[0], " ")[0] == "ORBInitRef" or string.split(l[0], " ")[0] == "InitRef" : |
292 |
my_port = int(l[len(l)-1]) |
293 |
pass |
294 |
s = file.read() |
295 |
pass |
296 |
except: |
297 |
pass |
298 |
|
299 |
args[port_nam] = my_port |
300 |
|
301 |
# ----------------------------------------------------------------------------- |
302 |
|
303 |
### command line options reader |
304 |
|
305 |
def options_parser(line): |
239 |
def options_parser(line): |
306 |
source = line |
240 |
source = line |
307 |
list = [] |
241 |
list = [] |
Lines 319-329
Link Here
|
319 |
if source[i][0] != '-': |
253 |
if source[i][0] != '-': |
320 |
key = None |
254 |
key = None |
321 |
elif source[i][1] == '-': |
255 |
elif source[i][1] == '-': |
322 |
key = source[i][2] |
256 |
key = source[i][2:] |
323 |
else: |
257 |
else: |
324 |
key = source[i][1] |
258 |
key = source[i][1:] |
325 |
pass |
259 |
pass |
326 |
|
260 |
|
|
|
261 |
if key is None and not result: |
262 |
raise Exception() |
327 |
result[key] = [] |
263 |
result[key] = [] |
328 |
if key: |
264 |
if key: |
329 |
i += 1 |
265 |
i += 1 |
Lines 337-454
Link Here
|
337 |
|
273 |
|
338 |
# ----------------------------------------------------------------------------- |
274 |
# ----------------------------------------------------------------------------- |
339 |
|
275 |
|
340 |
### read command-line options : each arg given in command line supersedes arg from xml config file |
276 |
### |
341 |
cmd_opts = {} |
277 |
# Get the environment |
342 |
try: |
278 |
### |
343 |
cmd_opts = options_parser(sys.argv[1:]) |
279 |
|
344 |
kernel_root_dir=os.environ["KERNEL_ROOT_DIR"] |
280 |
# this attribute is obsolete |
345 |
except: |
281 |
args = [] |
346 |
cmd_opts["h"] = 1 |
282 |
def get_env(): |
347 |
pass |
283 |
### |
|
|
284 |
# Collect launch configuration files: |
285 |
# - The environment variable "<appname>Config" (SalomeAppConfig) which can |
286 |
# define a list of directories (separated by ':' or ';' symbol) is checked |
287 |
# - If the environment variable "<appname>Config" is not set, only |
288 |
# ${GUI_ROOT_DIR}/share/salome/resources/gui is inspected |
289 |
# - ${GUI_ROOT_DIR}/share/salome/resources/gui directory is always inspected |
290 |
# so it is not necessary to put it in the "<appname>Config" variable |
291 |
# - The directories which are inspected are checked for files "<appname>.xml" |
292 |
# (SalomeApp.xml) which define SALOME configuration |
293 |
# - These directories are analyzed beginning from the last one in the list, |
294 |
# so the first directory listed in "<appname>Config" environment variable |
295 |
# has higher priority: it means that if some configuration options |
296 |
# is found in the next analyzed cofiguration file - it will be replaced |
297 |
# - The last configuration file which is parsed is user configuration file |
298 |
# situated in the home directory: "~/.<appname>rc[.<version>]" (~/SalomeApprc.3.2.0) |
299 |
# (if it exists) |
300 |
# - Command line options have the highest priority and replace options |
301 |
# specified in configuration file(s) |
302 |
### |
303 |
|
304 |
global args |
305 |
config_var = appname+'Config' |
306 |
|
307 |
# set resources variable SaloemAppConfig if it is not set yet |
308 |
dirs = [] |
309 |
if os.getenv(config_var): |
310 |
dirs += re.split('[;|:]', os.getenv(config_var)) |
311 |
if os.getenv("GUI_ROOT_DIR") and os.path.isdir( os.getenv("GUI_ROOT_DIR") + "/share/salome/resources/gui" ): |
312 |
dirs += [os.getenv("GUI_ROOT_DIR") + "/share/salome/resources/gui"] |
313 |
os.environ[config_var] = ":".join(dirs) |
314 |
|
315 |
dirs.reverse() # reverse order, like in "path" variable - FILO-style processing |
316 |
|
317 |
_opts = {} # associative array of options to be filled |
318 |
|
319 |
# parse SalomeApp.xml files in directories specified by SalomeAppConfig env variable |
320 |
for dir in dirs: |
321 |
filename = dir+'/'+appname+'.xml' |
322 |
if not os.path.exists(filename): |
323 |
print "Configure parser: Warning : could not find configuration file %s" % filename |
324 |
else: |
325 |
try: |
326 |
p = xml_parser(filename, _opts) |
327 |
_opts = p.opts |
328 |
except: |
329 |
print "Configure parser: Error : can not read configuration file %s" % filename |
330 |
pass |
348 |
|
331 |
|
349 |
### check all options are right |
332 |
# parse .SalomeApprc.<version> file in user's home directory if it exists |
|
|
333 |
# if user file for the current version is not found the nearest to it is used |
334 |
filename = userFile() |
335 |
if not filename or not os.path.exists(filename): |
336 |
print "Configure parser: Warning : could not find user configuration file" |
337 |
else: |
338 |
try: |
339 |
p = xml_parser(filename, _opts) |
340 |
_opts = p.opts |
341 |
except: |
342 |
print 'Configure parser: Error : can not read user configuration file' |
350 |
|
343 |
|
351 |
opterror=0 |
344 |
args = _opts |
352 |
for opt in cmd_opts: |
|
|
353 |
if not opt in ("h","g","l","f","x","m","e","s","c","p","k","t","i","r"): |
354 |
print "Configure parser: Error : command line error : -%s" % opt |
355 |
opterror=1 |
356 |
|
357 |
if opterror == 1: |
358 |
cmd_opts["h"] = 1 |
359 |
|
360 |
if cmd_opts.has_key("h"): |
361 |
print """USAGE: runSalome.py [options] |
362 |
[command line options] : |
363 |
--help or -h : print this help |
364 |
--gui or -g : launching with GUI |
365 |
--terminal -t : launching without gui (to deny --gui) |
366 |
or -t=PythonScript[,...] |
367 |
: import of PythonScript(s) |
368 |
--logger or -l : redirect messages in a CORBA collector |
369 |
--file=filename or -f=filename: redirect messages in a log file |
370 |
--xterm or -x : execute servers in xterm console (messages appear in xterm windows) |
371 |
--modules=module1,module2,... : salome module list (modulen is the name of Salome module to load) |
372 |
or -m=module1,module2,... |
373 |
--embedded=registry,study,moduleCatalog,cppContainer |
374 |
or -e=registry,study,moduleCatalog,cppContainer |
375 |
: embedded CORBA servers (default: registry,study,moduleCatalog,cppContainer) |
376 |
: (logger,pyContainer,supervContainer can't be embedded |
377 |
--standalone=registry,study,moduleCatalog,cppContainer,pyContainer,supervContainer |
378 |
or -s=registry,study,moduleCatalog,cppContainer,pyContainer,supervContainer |
379 |
: standalone CORBA servers (default: pyContainer,supervContainer) |
380 |
--containers=cpp,python,superv: (obsolete) launching of containers cpp, python and supervision |
381 |
or -c=cpp,python,superv : = get default from -e and -s |
382 |
--portkill or -p : kill the salome with current port |
383 |
--killall or -k : kill all salome sessions |
384 |
--interp=n or -i=n : number of additional xterm to open, with session environment |
385 |
-z : display splash screen |
386 |
-r : disable centralized exception handling mechanism |
387 |
|
388 |
For each Salome module, the environment variable <modulen>_ROOT_DIR must be set. |
389 |
The module name (<modulen>) must be uppercase. |
390 |
KERNEL_ROOT_DIR is mandatory. |
391 |
""" |
392 |
sys.exit(1) |
393 |
pass |
394 |
|
345 |
|
395 |
### apply command-line options to the arguments |
346 |
# set default values for options which are NOT set in config files |
396 |
for opt in cmd_opts: |
347 |
for aKey in listKeys: |
397 |
if opt == 'g': |
348 |
if not args.has_key( aKey ): |
398 |
args[gui_nam] = 1 |
349 |
args[aKey]=[] |
399 |
elif opt == 'z': |
|
|
400 |
args[splash_nam] = 1 |
401 |
elif opt == 'r': |
402 |
args[except_nam] = 1 |
403 |
elif opt == 'l': |
404 |
args[logger_nam] = 1 |
405 |
elif opt == 'f': |
406 |
args[file_nam] = cmd_opts['f'] |
407 |
elif opt == 'x': |
408 |
args[xterm_nam] = 1 |
409 |
elif opt == 'i': |
410 |
args[interp_nam] = cmd_opts['i'] |
411 |
elif opt == 'm': |
412 |
args[modules_nam] = cmd_opts['m'] |
413 |
elif opt == 'e': |
414 |
args[embedded_nam] = cmd_opts['e'] |
415 |
elif opt == 's': |
416 |
args[standalone_nam] = cmd_opts['s'] |
417 |
elif opt == 'c': |
418 |
args[containers_nam] = cmd_opts['c'] |
419 |
elif opt == 'p': |
420 |
args[portkill_nam] = 1 |
421 |
elif opt == 'k': |
422 |
args[killall_nam] = 1 |
423 |
pass |
424 |
pass |
425 |
|
350 |
|
426 |
# if --modules (-m) command line option is not given |
351 |
for aKey in boolKeys: |
427 |
# try SALOME_MODULES environment variable |
352 |
if not args.has_key( aKey ): |
428 |
if not cmd_opts.has_key( "m" ) and os.getenv( "SALOME_MODULES" ): |
353 |
args[aKey]=0 |
429 |
args[modules_nam] = re.split( "[:;,]", os.getenv( "SALOME_MODULES" ) ) |
|
|
430 |
pass |
431 |
|
354 |
|
432 |
# 'terminal' must be processed in the end: to deny any 'gui' options |
355 |
if args[file_nam]: |
433 |
args[script_nam] = [] |
356 |
afile=args[file_nam] |
434 |
if 't' in cmd_opts: |
357 |
args[file_nam]=[afile] |
435 |
args[gui_nam] = 0 |
|
|
436 |
args[script_nam] = cmd_opts['t'] |
437 |
pass |
438 |
|
358 |
|
439 |
if args[except_nam] == 1: |
359 |
args[appname_nam] = appname |
440 |
os.environ["DISABLE_FPE"] = "1" |
360 |
|
441 |
pass |
361 |
# get the port number |
|
|
362 |
my_port = 2809 |
363 |
try: |
364 |
file = open(os.environ["OMNIORB_CONFIG"], "r") |
365 |
s = file.read() |
366 |
while len(s): |
367 |
l = string.split(s, ":") |
368 |
if string.split(l[0], " ")[0] == "ORBInitRef" or string.split(l[0], " ")[0] == "InitRef" : |
369 |
my_port = int(l[len(l)-1]) |
370 |
pass |
371 |
s = file.read() |
372 |
pass |
373 |
except: |
374 |
pass |
375 |
|
376 |
args[port_nam] = my_port |
377 |
|
378 |
# read command-line options |
379 |
# each option given in command line overrides the option from xml config file |
380 |
cmd_opts = {} |
381 |
try: |
382 |
cmd_opts = options_parser(sys.argv[1:]) |
383 |
kernel_root_dir=os.environ["KERNEL_ROOT_DIR"] |
384 |
except: |
385 |
cmd_opts["h"] = 1 |
386 |
pass |
442 |
|
387 |
|
443 |
# now modify SalomeAppConfig environment variable |
388 |
# check if all command line options are correct |
444 |
dirs = re.split('[;|:]', os.environ[config_var] ) |
389 |
short_opts = ("h","g","l","f","x","m","e","s","c","p","k","t","i","r","z") |
|
|
390 |
long_opts = (help_nam,gui_nam,logger_nam,file_nam,xterm_nam,modules_nam, |
391 |
embedded_nam,standalone_nam,containers_nam,portkill_nam, |
392 |
killall_nam,terminal_nam,interp_nam,except_nam,splash_nam, |
393 |
case_nam) |
394 |
opterror=0 |
395 |
for opt in cmd_opts: |
396 |
if opt not in short_opts and opt not in long_opts: |
397 |
print "Configure parser: Error : command line error : -%s" % opt |
398 |
opterror=1 |
399 |
|
400 |
if opterror == 1: |
401 |
cmd_opts["h"] = 1 |
402 |
|
403 |
if cmd_opts.has_key("h") or cmd_opts.has_key(help_nam): |
404 |
print """ |
405 |
USAGE: runSalome.py [options] |
406 |
|
407 |
Command line options: |
408 |
|
409 |
--gui (-g) Launch in GUI mode [default]. |
410 |
--terminal (-t) Launching without GUI (in the terminal mode). |
411 |
--terminal=<python_script>[,...] Launching without GUI (in the terminal mode) and |
412 |
(-t=<python_script>[,...]) additionally import python script(s). |
413 |
--logger (-l) Redirect messages to the CORBA collector. |
414 |
--file=<file> (-f=<file>) Redirect messages to the log file. |
415 |
--xterm (-x) Launch each SALOME server in own xterm console. |
416 |
--modules=<module1>,<module2>,... SALOME module list (where <module1>, <module2> |
417 |
(-m=<module1>,<module2>,...) are the names of SALOME modules which should be |
418 |
available in the SALOME session). |
419 |
--embedded=<server1>,<server2>,... CORBA servers to be launched in the Session |
420 |
(-e=<server1>,<server2>,...) embedded mode. |
421 |
Valid values for <serverN>: registry, study, |
422 |
moduleCatalog, cppContainer |
423 |
[default: all mentioned]. |
424 |
--standalone=<server1>,<server2>,... CORBA servers to be launched in the standalone |
425 |
(-s=<server1>,<server2>,...) mode (as separate processes). |
426 |
Valid values for <serverN>: registry, study, |
427 |
moduleCatalog, cppContainer, pyContainer, |
428 |
supervContainer |
429 |
[default: pyContainer,supervContainer]. |
430 |
--containers=<container1>,... [obsolete] SALOME containers to be launched. |
431 |
(-c=<container1>,...) Valid values: cpp, python, superv |
432 |
[default: use --embedded and --standalone |
433 |
parameters]. |
434 |
--portkill (-p) Kill SALOME with the current port. |
435 |
--killall (-k) Kill all running SALOME sessions. |
436 |
--interp=<N> (-i=<N>) The number of additional xterm sessions to open. |
437 |
In each xterm session SALOME environment is set |
438 |
properly. |
439 |
--splash (-z) Display splash screen. |
440 |
--noexcepthandler (-r) Disable centralized exception handling |
441 |
mechanism. |
442 |
--test=<hdf_file_andor_python_scripts> HDF file to be opened on GUI starting and/or |
443 |
Python script(s) to be imported in the GUI |
444 |
study. The files can appear in arbitrary order. |
445 |
If the HDF file is given it is opened, otherwise |
446 |
the new empty study is created. |
447 |
Python scripts are imported in the order of |
448 |
their appearance. |
449 |
This option is avaiable only in GUI mode, |
450 |
for batch mode use --terminal(-t) option. |
451 |
--help (-h) Print this help info |
452 |
|
453 |
For each SALOME module, the environment variable <moduleN>_ROOT_DIR must be set. |
454 |
KERNEL_ROOT_DIR is mandatory. |
455 |
""" |
456 |
sys.exit(1) |
457 |
pass |
458 |
|
459 |
# apply command-line options to the arguments |
460 |
BATCHMODE_FORCED = False |
461 |
args[script_nam] = [] |
462 |
for opt in cmd_opts: |
463 |
if opt in [ 'g', gui_nam ] : |
464 |
if not BATCHMODE_FORCED: args[gui_nam] = 1 |
465 |
elif opt in [ 't', terminal_nam ] : |
466 |
args[gui_nam] = 0 |
467 |
args[script_nam] = cmd_opts[opt] |
468 |
BATCHMODE_FORCED = True |
469 |
elif opt in [ 'z', splash_nam ] : |
470 |
args[splash_nam] = 1 |
471 |
elif opt in [ 'r', except_nam ] : |
472 |
args[except_nam] = 1 |
473 |
elif opt in [ 'l', logger_nam ] : |
474 |
args[logger_nam] = 1 |
475 |
elif opt in [ 'f', file_nam ] : |
476 |
args[file_nam] = cmd_opts[opt] |
477 |
elif opt in [ 'x', xterm_nam ] : |
478 |
args[xterm_nam] = 1 |
479 |
elif opt in [ 'i', interp_nam ] : |
480 |
args[interp_nam] = cmd_opts[opt] |
481 |
elif opt in [ 'm', modules_nam ] : |
482 |
args[modules_nam] = cmd_opts[opt] |
483 |
elif opt in [ 'e', embedded_nam ] : |
484 |
args[embedded_nam] = cmd_opts[opt] |
485 |
elif opt in [ 's', standalone_nam ] : |
486 |
args[standalone_nam] = cmd_opts[opt] |
487 |
elif opt in [ 'c', containers_nam ] : |
488 |
args[containers_nam] = cmd_opts[opt] |
489 |
elif opt in [ 'p', portkill_nam ] : |
490 |
args[portkill_nam] = 1 |
491 |
elif opt in [ 'k', killall_nam ] : |
492 |
args[killall_nam] = 1 |
493 |
elif opt in [ case_nam ] : |
494 |
args[case_nam] = cmd_opts[opt] |
495 |
pass |
496 |
|
497 |
# if --modules (-m) command line option is not given |
498 |
# try SALOME_MODULES environment variable |
499 |
if not cmd_opts.has_key( "m" ) and \ |
500 |
not cmd_opts.has_key( modules_nam ) and \ |
501 |
os.getenv( "SALOME_MODULES" ): |
502 |
args[modules_nam] = re.split( "[:;,]", os.getenv( "SALOME_MODULES" ) ) |
503 |
pass |
504 |
|
505 |
# disable signals handling |
506 |
if args[except_nam] == 1: |
507 |
os.environ["NOT_INTERCEPT_SIGNALS"] = "1" |
508 |
pass |
509 |
|
510 |
# now modify SalomeAppConfig environment variable |
511 |
# to take into account the SALOME modules |
512 |
dirs = re.split('[;|:]', os.environ[config_var] ) |
513 |
|
514 |
for m in args[modules_nam]: |
515 |
if m not in ["KERNEL", "GUI", ""] and os.getenv("%s_ROOT_DIR"%m): |
516 |
d1 = os.getenv("%s_ROOT_DIR"%m) + "/share/salome/resources/" + m.lower() |
517 |
d2 = os.getenv("%s_ROOT_DIR"%m) + "/share/salome/resources" |
518 |
if os.path.exists( "%s/%s.xml"%(d1, appname) ): |
519 |
dirs.append( d1 ) |
520 |
elif os.path.exists( "%s/%s.xml"%(d2, appname) ): |
521 |
dirs.append( d2 ) |
522 |
os.environ[config_var] = ":".join(dirs) |
445 |
|
523 |
|
446 |
for m in args[modules_nam]: |
524 |
# return arguments |
447 |
if m not in ["KERNEL", "GUI", ""] and os.getenv("%s_ROOT_DIR"%m): |
525 |
return args |
448 |
d1 = os.getenv("%s_ROOT_DIR"%m) + "/share/salome/resources/" + m.lower() |
|
|
449 |
d2 = os.getenv("%s_ROOT_DIR"%m) + "/share/salome/resources" |
450 |
if os.path.exists( "%s/%s.xml"%(d1, appname) ): |
451 |
dirs.append( d1 ) |
452 |
elif os.path.exists( "%s/%s.xml"%(d2, appname) ): |
453 |
dirs.append( d2 ) |
454 |
os.environ[config_var] = ":".join(dirs) |