Version: 9.7.0
KERNEL Services for end user (Python interface)


In a SALOME application, distributed components, servers and clients use the CORBA middleware for communication.

CORBA interfaces are defined via idl files. All the different CORBA interfaces are available for users in Python, see CORBA interfaces below.

For some general purpose services, CORBA interfaces have been encapsulated in order to provide a simple interface (encapsulation is generally done in C++ classes, and a Python SWIG interface is also generated from C++, to ensure a consistent behavior between C++ modules and Python modules or user script).

General purpose services

SALOME services access from a Python shell

See Salome Application Concept for detailed instructions on how to launch a Python interpreter with full access to the SALOME environment and services.

You can use the embedded Python interpreter in Graphical User Interface, or an external interpreter, with:

python

In either cases, SALOME services access is done with:

import salome
salome.salome_init()

In the embedded interpreter, it is already done, but there is no problem to do it several times, so it is preferable to add these instructions systematically in your scripts, to allow them to work in all configurations. See Using salome.py module for a short description of most useful variables and functions.

Container and component instantiation

See SALOME_LifeCycleCORBA for the C++ interface (Python interface obtained with SWIG is very similar).

In the following example, a test component provided in KERNEL is launched in the local container, "FactoryServer", created when SALOME starts:

import salome
salome.salome_init()
obj=lcc.FindOrLoad_Component("FactoryServer","SalomeTestComponent")
import Engines
comp.Coucou(1)


The answer is something like:

'TestComponent_i : L = 1'

The _narrow() instruction is not always mandatory in Python, but sometimes useful to be sure you have got the right type of object. Here, Testcomponent interface is defined in CORBA module Engines. With this example, it works also without the _narrow() instruction:

obj.Coucou(1)

In the next example, a component instance is created in a specific Container defined by it's computer hostname and it's name. Here we use the local computer. Note that in Utils_Identity, Utils_Identity::getShortHostName() gives the short hostname of the computer, without domain suffixes, which is used in SALOME. The container process is created here if it does not exists, and a new component instance is created:

import salome
salome.salome_init()
host = Utils_Identity.getShortHostName()
import Engines
params={}
params['hostname']=host
params['container_name']='myContainer'
comp=lcc.LoadComponent(params,'SalomeTestComponent')
comp.Coucou(1)

If you want to get a list of containers and component instances, client object from orbmodule provides a list:

import orbmodule
clt.showNS()

The list looks like:

ContainerManager.object
Containers.dir
cli70ac.dir
FactoryServerPy.object
SuperVisionContainer.object
FactoryServer.object
FactoryServer.dir
SalomeTestComponent_inst_1.object
myContainer.object
myContainer.dir
SalomeTestComponent_inst_1.object
SalomeTestComponent_inst_2.object
Registry.object
Kernel.dir
ModulCatalog.object
Session.object
Study.dir
Study2.object
extStudy_1.object
extStudy_2.object
extStudy_3.object
SalomeAppEngine.object

File transfer service

See SALOME_FileTransferCORBA for the C++ interface (Python interface obtained with SWIG is very similar).

The following example shows how to transfer a file from a remote host to the client computer. Remote hostname is 'cli76cc', we would like to copy 'tkcvs_8_0_3.tar.gz' from remote to local computer. A full pathname is required. A container is created on remote computer if it does not exist, to handle the file transfer:

import salome
salome.salome_init()
remotefile="/home/prascle/tkcvs_8_0_3.tar.gz"
aFileTransfer=LifeCycleCORBA.SALOME_FileTransferCORBA('cli76cc',remotefile)
localFile=aFileTransfer.getLocalFile()

CORBA Naming service access

See SALOME_NamingService for the C++ interface. The Python interface SALOME_NamingServicePy::SALOME_NamingServicePy_i is not yet derived from the C++ interface and offers only the most useful functions.

All IDL Interfaces

  1. Containers and component life cycle, File transfer service
  2. Study management
    • SALOMEDS : SALOMEDS CORBA module
    • SALOMEDS.idl : This file contains a set of interfaces used for creation, management and modification of the Study.
    • SALOMEDS_Attributes.idl : This file contains a set of interfaces for the attributes which can be assigned to SObject.
  3. High speed transfer, object life cycle, exceptions, GUI interface...
    • SALOME : Module SALOME contains all base interfaces of SALOME Kernel.
    • SALOME_Comm.idl : This file contains a set of interfaces used for communication between components.
    • SALOME_GenericObj.idl : interface for common behavior of SALOME transient CORBA objects
    • SALOME_Exception.idl : This file contains the objects defining the main exception used in SALOME application.
    • SALOME_Session.idl : file that contains interface of the session
  4. Miscelleanous
    • SALOME_ModuleCatalog : The main package of interfaces used for the module catalog in SALOME application.
    • SALOME_RessourcesCatalog :
    • Registry : module that provides interface to SALOME registry
    • SALOME_Logger : module that provides interface to SALOME logger
  5. Other idl for test purposes
  6. Some useful command scripts
    • waitNS.py : command to wait until module catalog server is launched
    • waitContainers.py : command to wait until containers are launched
    • showNS.py : display the contents of SALOME naming service
    • shutdownSalome.py :
    • killSalome.py : Forcibly stop all running SALOME sessions.
    • killSalomeWithPort.py : Forcibly stop SALOME processes from given session(s).
    • appli_gen.py : Create a SALOME application (virtual Salome installation)