To start SALOME a new approach has been introduced in versions 7.x, based on Salome Application Concept. The underlying mechanism aims at:
Usage of salome
command is:
Commands are:
start
context
shell
connect
kill
<port(s)> killall
test
info
doc
<module(s)> help
If no command is given, default is start.
Use salome <command> –help to show help on command? Available for the following commands: start, shell, connect, test, info.
To start an application, use
To see available options for this command, use
To initialize SALOME context, use
To see available options for this command, use
To connect a Python console, use
There is no options to this command. It asks user which SALOME instance to connect to.
The –config
option is used to identify the list of configuration files or directories to be used for SALOME context creation. When this option is given, only files provided by user are considered. If user does not specify any context file SALOME will rely on context files detected in the env.d application folder. Context files have the .cfg extension.
To initialize application context, the salome
command parses all context files in the env.d folder. User can add her own context files (see Syntax of a context file).
On the one hand, runAppli options allow to give a list of Python scripts to be run after application startup; but it is not possible to specify parameters for these scripts. On the other hand runSession can run one script but it admits several parameters.
The salome
command options allow to give a list of Python scripts to be run after application startup. It is possible to specify parameters for each of these scripts. To provide parameters to a script from the command line, write script.py args:arg1,arg2,...,argn
The script parameters must be separated by commas and no spaces are allowed (except between the script name and the beginning of its parameters). For example, the following call will run sequentially three scripts, which will wait 5 seconds, say hello, and calculate 1+2+3:
The command salome
shell
allows a double dash syntax (- -) to indicate an extra command to be run "as is". It allows calling a extern program or system command having options and arguments that contain simple dash (-) characters. The syntax is
For example:
A SALOME instance uses a dedicated TCP port number on which the CORBA name server of each SALOME application will connect. This refers to a technical solution that allows multiple software components belonging to the same application to communicate with each other. This approach is a standard used when multiple applications are running at the same time (components should not interfere with each other), and when application components can be distributed across multiple machines.
Each SALOME application owns a specific port number. This port is determined automatically when application starts. When multiple applications are started at the same time, assigning a number to each port could be conflicting, and the same port could be assigned to several applications. To prevent from such a situation, a Python object named Portmanager
has been implemented. This object has been introduced in SALOME 7 as an optional tool, then evaluated on Linux and Windows. In SALOME 8, this object becomes the standard.
Several instances can be safely started concurrently. For example in an automated process in shell script, calling several times the following commands (WORK_DIR variable changes at each call):
From a Python script, use a SalomeInstance object:
With salome
shell
user can connect to a SALOME instance running on a remote computer. In this case the options -p PORT
, -m MACHINE
, -d DIRECTORY
and -u USER
must be provided. Moreover the syntax out:res1,res2,...
can be used to get results back from remote machine. For example:
In this example user myself
connects to remotemachine
to run the script concatenate.py
in a SALOME instance running on port 2810
. The script takes two input parameters and produces one result file. The script and the input files are on the local computer. They are copied to the remote machine using a secure connection. Results produced on remote computer are transferred on the local machine using the same protocol. Script, input files and results are finally removed from remote machine.
A launcher is a Python module that contains a single main(args)
function to sequentially execute the following operations:
This module is generally used as a script, run from a shell command line. It thus contains the directive:
Finally the module can be called from another script, for example a test script. Considering a Python variable path_to_launcher
that identifies the absolute path to a launcher, one can write:
An API named SalomeContext
, written in Python, allows for the construction of SALOME execution context and for application start. Each launcher creates a SalomeContext
object, and optionally gives it a list of configuration files to describe the context:
A launcher can also directly call the API functions to define, suppress or extend (add information) an environment variable:
The addToVariable
function consists in prefixing the variable name with the given value inserting a separator between the two items.
Unix system variables PATH, LD_LIBRARY_PATH (DYLD_LIBRARY PATH for BSD) and PYTHONPATH can only be extended:
Once the context is created, the application is started:
The args
list corresponds to commands and options given to salome
launcher.
It is possible to write specific context files provided that the syntax defined hereinafter is respected. Their analysis by the new SALOME start mechanism uses tools from the Python standard API.
A context file starts with a section title, and continues with the definition of different context variables. The section title is a string enclosed by brackets, for example [My context]
.
A variable can be defined with a declaration variable=value
:
A variable can be defined relative to another one; this substitution corresponds to the syntax %(variable)s
:
In this example QTDIR will equal ${HOME}/salome/prerequisites/install/Qt-484
Specific system variables such as PATH, LD_LIBRARY_PATH, DYLD_LIBRARY_PATH and PYTHONPATH are extended with ADD_TO_variable: valeur
.
This prepends environment variables with user paths.
A variable can be unset with UNSET: variable
: