-# Copyright (C) 2005 OPEN CASCADE, CEA, EDF R&D, LEG
-# PRINCIPIA R&D, EADS CCR, Lip6, BV, CEDRAT
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License.
+# -*- coding: iso-8859-1 -*-
+# Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
#
-# This library is distributed in the hope that it will be useful
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
+# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
#
-# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
import os, glob, string, sys, re
terminal_nam = "terminal"
pinter_nam = "pinter"
batch_nam = "batch"
+test_nam = "test"
+play_nam = "play"
+gdb_session_nam = "gdb_session"
+ddd_session_nam = "ddd_session"
+shutdown_servers_nam = "shutdown_servers"
# values in XML configuration file giving specific module parameters (<module_name> section)
# which are stored in opts with key <module_name>_<parameter> (eg SMESH_plugins)
# possible choices for the "embedded" and "standalone" parameters
embedded_choices = [ "registry", "study", "moduleCatalog", "cppContainer", "SalomeAppEngine" ]
-standalone_choices = [ "registry", "study", "moduleCatalog", "cppContainer", "pyContainer", "supervContainer"]
+standalone_choices = [ "registry", "study", "moduleCatalog", "cppContainer", "pyContainer"]
# values of boolean type (must be '0' or '1').
# xml_parser.boolValue() is used for correct setting
-boolKeys = ( gui_nam, splash_nam, logger_nam, file_nam, xterm_nam, portkill_nam, killall_nam, except_nam, pinter_nam )
+boolKeys = ( gui_nam, splash_nam, logger_nam, file_nam, xterm_nam, portkill_nam, killall_nam, except_nam, pinter_nam, shutdown_servers_nam )
intKeys = ( interp_nam, )
# values of list type
help_str = "Python script(s) to be imported. Python scripts are imported "
help_str += "in the order of their appearance. In GUI mode python scripts "
help_str += "are imported in the embedded python interpreter of current study, "
- help_str += "otherwise in an external python interpreter"
+ help_str += "otherwise in an external python interpreter. "
+ help_str += "Note: this option is obsolete. Instead you can pass Python script(s) "
+ help_str += "directly as positional parameter."
o_u = optparse.Option("-u",
"--execute",
metavar="<script1,script2,...>",
dest="ns_port_log_file",
help=help_str)
+ # Write/read test script file with help of TestRecorder. Default: False.
+ help_str = "Write/read test script file with help of TestRecorder."
+ o_test = optparse.Option("--test",
+ metavar="<test_script_file>",
+ type="string",
+ action="store",
+ dest="test_script_file",
+ help=help_str)
+
+ # Reproducing test script with help of TestRecorder. Default: False.
+ help_str = "Reproducing test script with help of TestRecorder."
+ o_play = optparse.Option("--play",
+ metavar="<play_script_file>",
+ type="string",
+ action="store",
+ dest="play_script_file",
+ help=help_str)
+
+ # gdb session
+ help_str = "Launch session with gdb"
+ o_gdb = optparse.Option("--gdb-session",
+ action="store_true",
+ dest="gdb_session", default=False,
+ help=help_str)
+
+ # ddd session
+ help_str = "Launch session with ddd"
+ o_ddd = optparse.Option("--ddd-session",
+ action="store_true",
+ dest="ddd_session", default=False,
+ help=help_str)
+
+ # shutdown-servers. Default: False.
+ help_str = "1 to shutdown standalone servers when leaving python interpreter, "
+ help_str += "0 to keep the standalone servers as daemon [default]. "
+ help_str += "This option is only useful in batchmode "
+ help_str += "(terminal mode or without showing desktop)."
+ o_shutdown = optparse.Option("--shutdown-servers",
+ metavar="<1/0>",
+ #type="choice", choices=boolean_choices,
+ type="string",
+ action="callback", callback=store_boolean, callback_args=('shutdown_servers',),
+ dest="shutdown_servers",
+ help=help_str)
+
# All options
opt_list = [o_t,o_g, # GUI/Terminal
o_d,o_o, # Desktop
o_a, # Print free port and exit
o_n, # --nosave-config
o_pi, # Interactive python console
- o_nspl]
-
+ o_nspl,
+ o_test, # Write/read test script file with help of TestRecorder
+ o_play, # Reproducing test script with help of TestRecorder
+ o_gdb,
+ o_ddd,
+ o_shutdown,
+ ]
#std_options = ["gui", "desktop", "log_file", "py_scripts", "resources",
# "xterm", "modules", "embedded", "standalone",
opt_list += theAdditionalOptions
- a_usage = "%prog [options] [STUDY_FILE]"
+ a_usage = "%prog [options] [STUDY_FILE] [PYTHON_FILE [PYTHON_FILE ...]]"
version_str = "Salome %s" % version()
pars = optparse.OptionParser(usage=a_usage, version=version_str, option_list=opt_list)
dirs += re.split(';', os.getenv(config_var))
else:
dirs += re.split('[;|:]', os.getenv(config_var))
-
+
+ gui_available = True
if os.getenv("GUI_ROOT_DIR") and os.path.isdir( os.getenv("GUI_ROOT_DIR") + "/share/salome/resources/gui" ):
dirs += [os.getenv("GUI_ROOT_DIR") + "/share/salome/resources/gui"]
+ pass
+ else:
+ gui_available = False
+ if os.getenv("KERNEL_ROOT_DIR") and os.path.isdir( os.getenv("KERNEL_ROOT_DIR") + "/bin/salome/appliskel" ):
+ dirs += [os.getenv("KERNEL_ROOT_DIR") + "/bin/salome/appliskel"]
+ pass
os.environ[config_var] = separator.join(dirs)
dirs.reverse() # reverse order, like in "path" variable - FILO-style processing
args[gui_nam] = cmd_opts.gui
if cmd_opts.batch is not None:
args[batch_nam] = True
+
+ if not gui_available:
+ args[gui_nam] = False
+
if args[gui_nam]:
args["session_gui"] = True
if cmd_opts.desktop is not None:
if args["session_gui"]:
if cmd_opts.splash is not None:
args[splash_nam] = cmd_opts.splash
- if len(cmd_args) > 0:
- args["study_hdf"] = cmd_args[0]
else:
args["session_gui"] = False
args[splash_nam] = False
listlist = cmd_opts.py_scripts
for listi in listlist:
args[script_nam] += re.split( "[:;,]", listi)
+ for arg in cmd_args:
+ if arg[-3:] == ".py":
+ args[script_nam].append(arg)
+ elif not args["study_hdf"]:
+ args["study_hdf"] = arg
+ pass
+ pass
# xterm
if cmd_opts.xterm is not None: args[xterm_nam] = cmd_opts.xterm
# Interactive python console
if cmd_opts.pinter is not None:
args[pinter_nam] = cmd_opts.pinter
-
+
+ # Gdb session in xterm
+ if cmd_opts.gdb_session is not None:
+ args[gdb_session_nam] = cmd_opts.gdb_session
+
+ # Ddd session in xterm
+ if cmd_opts.ddd_session is not None:
+ args[ddd_session_nam] = cmd_opts.ddd_session
+
+ # Shutdown servers
+ if cmd_opts.shutdown_servers is None:
+ args[shutdown_servers_nam] = 0
+ else:
+ args[shutdown_servers_nam] = cmd_opts.shutdown_servers
+ pass
+
####################################################
# Add <theAdditionalOptions> values to args
for add_opt in theAdditionalOptions:
elif os.path.exists( "%s/%s.xml"%(d2, salomeappname) ):
dirs.append( d2 )
+ # Test
+ if cmd_opts.test_script_file is not None:
+ args[test_nam] = []
+ filename = cmd_opts.test_script_file
+ args[test_nam] += re.split( "[:;,]", filename )
+
+ # Play
+ if cmd_opts.play_script_file is not None:
+ args[play_nam] = []
+ filename = cmd_opts.play_script_file
+ args[play_nam] += re.split( "[:;,]", filename )
+
# return arguments
os.environ[config_var] = separator.join(dirs)
#print "Args: ", args