Set of utility functions used by SALOME python scripts.
More...
|
list | __all__ |
|
| _verbose = None |
|
Set of utility functions used by SALOME python scripts.
def salome_utils.getORBcfgInfo |
( |
| ) |
|
Get omniORB current configuration.
Returns a list of three values: [ orb_version, host_name, port_number ].
The information is retrieved from the omniORB configuration file defined
by the OMNIORB_CONFIG environment variable.
If omniORB configuration file can not be accessed, a list of three empty
strings is returned.
def salome_utils.getHostFromORBcfg |
( |
| ) |
|
Get current omniORB host.
def salome_utils.getPortFromORBcfg |
( |
| ) |
|
Get current omniORB port.
def salome_utils.getUserName |
( |
| ) |
|
Get user name:
1. try USER environment variable (USERNAME on windows)
2. if fails, try LOGNAME (un*x)
3. if fails return 'unknown' as default user name
def salome_utils.getHostName |
( |
| ) |
|
Get host name:
1. try socket python module gethostname() function
2. if fails, try HOSTNAME environment variable
3. if fails, try HOST environment variable
4. if fails, return 'unknown' as default host name
def salome_utils.getShortHostName |
( |
| ) |
|
Get short host name:
1. try socket python module gethostname() function
2. if fails, try HOSTNAME environment variable
3. if fails, try HOST environment variable
4. if fails, return 'unknown' as default host name
def salome_utils.getAppName |
( |
| ) |
|
Get application name:
1. try APPNAME environment variable
2. if fails, return 'SALOME' as default application name
def salome_utils.getPortNumber |
( |
|
use_default = True | ) |
|
Get current naming server port number:
1. try NSPORT environment variable
1. if fails, try to parse config file defined by OMNIORB_CONFIG environment variable
2. if fails, return 2809 as default port number (if use_default is True) or None (id use_default is False)
def salome_utils.getHomeDir |
( |
| ) |
|
def salome_utils.getLogDir |
( |
| ) |
|
Get directory to be used for the log files.
def salome_utils.getTmpDir |
( |
| ) |
|
Get directory to be used for the temporary files.
def salome_utils.generateFileName |
( |
|
dir, |
|
|
|
prefix = None , |
|
|
|
suffix = None , |
|
|
|
extension = None , |
|
|
|
unique = False , |
|
|
|
separator = "_" , |
|
|
|
hidden = False , |
|
|
|
kwargs |
|
) |
| |
Generate file name by sepecified parameters. If necessary, file name
can be generated to be unique.
Parameters:
- dir : directory path
- prefix : file prefix (not added by default)
- suffix : file suffix (not added by default)
- extension : file extension (not added by default)
- unique : if this parameter is True, the unique file name is generated:
in this case, if the file with the generated name already exists
in the <dir> directory, an integer suffix is added to the end of the
file name. This parameter is False by default.
- separator : separator of the words ('_' by default)
- hidden : if this parameter is True, the file name is prepended by . (dot)
symbol. This parameter is False by default.
Other keyword parameters are:
- with_username : 'add user name' flag/option:
* boolean value can be passed to determine user name automatically
* string value to be used as user name
- with_hostname : 'add host name' flag/option:
* boolean value can be passed to determine host name automatically
* string value to be used as host name
- with_port : 'add port number' flag/option:
* boolean value can be passed to determine port number automatically
* string value to be used as port number
- with_app : 'add application name' flag/option:
* boolean value can be passed to determine application name automatically
* string value to be used as application name
All <with_...> parameters are optional.
def salome_utils.makeTmpDir |
( |
|
path, |
|
|
|
mode = 0777 |
|
) |
| |
Make temporary directory with the specified path.
If the directory exists then clear its contents.
Parameters:
- path : absolute path to the directory to be created.
- mode : access mode
def salome_utils.uniteFiles |
( |
|
src_file, |
|
|
|
dest_file |
|
) |
| |
Unite contents of the source file with contents of the destination file
and put result of the uniting to the destination file.
If the destination file does not exist then the source file is simply
copied to its path.
Parameters:
- src_file : absolute path to the source file
- dest_file : absolute path to the destination file
def salome_utils.verbose |
( |
| ) |
|
Get verbosity level. Default verbosity level is specified via the environment variable
SALOME_VERBOSE, e.g.:
[bash %] export SALOME_VERBOSE=1
The function setVerbose() can be used to change verbosity level explicitly.
def salome_utils.setVerbose |
( |
|
level | ) |
|
Change verbosity level. The function verbose() can be used to get current verbosity level.
def salome_utils.killpid |
( |
|
pid, |
|
|
|
sig = 9 |
|
) |
| |
Send signal sig to the process by pid.
Parameters:
- pid : PID of process
- sig : signal for sending
Possible values of signals:
9 means kill the process
0 only check existing of the process
NOTE: Other values are not processed on Windows
Returns:
1 Success
0 Fail, no such process
-1 Fail, another reason
def salome_utils.getOmniNamesPid |
( |
|
port | ) |
|
Return OmniNames pid by port number.
def salome_utils.killOmniNames |
( |
|
port | ) |
|
Kill OmniNames process by port number.
list salome_utils.__all__ |