run_aster package¶
code_aster can be used as a standard Python module, see code_aster package.
For convenience and when code_aster is executed from a graphical interface,
a study is usually defined by a .export file.
The installation provides a script bin/run_aster to execute a study
from a such file.
The run_aster package contains the Python source files used by
bin/run_aster and bin/run_ctest.
bin/run_aster — Script to execute code_aster¶
bin/run_aster executes a code_aster study from the command line.
The parameters and files used by the study are defined in a .export file
(see export for description of the syntax of the
.export).
For parallel executions, these two forms are equivalent (if the .export
contains P mpi_nbcpu 4):
bin/run_aster path/to/file.export
or:
mpiexec -n 4 bin/run_aster path/to/file.export
Using the first syntax, bin/run_aster re-runs itself with mpiexec using
the second syntax (mpiexec syntax is provided by the configuration, see
config).
If the version has been configured with --use-srun, you must use:
bin/run_aster path/to/file.export
or:
srun -n 4 [options] bin/run_aster path/to/file.export
bin/run_aster can also directly execute a Python file (.py or .comm
extension is expected) with code_aster commands.
In this case, no data or result files are managed by run_aster and
default values are used for memory and time limit (use options to change
these values).
bin/run_aster path/to/file.py
Data files may be referenced in the Python file with relative paths from the
parent directory of file.py using, for example, os.path.dirname(__file__).
For the parallel version:
mpiexec -n 2 bin/run_aster --only-proc0 path/to/file.py
or:
bin/run_aster -n 2 --only-proc0 path/to/file.py
bin/run_aster only runs its own version, those installed at the level of
the bin directory; unlike as_run where the same instance of as_run
executes several versions of code_aster.
This makes bin/run_aster simpler and allows per version settings
(see config for more informations about the configuration
of a version).
More options are available to execute code_aster with an interactive Python
interpreter, to prepare a working directory and to start manually (through
a debugger for example)…
For example, executing bin/run_aster with no .export file starts an
interactive Python interpreter.
See bin/run_aster --help for the available options.
bin/run_ctest — Script to execute code_aster testcases using ctest¶
bin/run_ctest executes code_aster testcases using ctest.
Usage:
bin/run_ctest [options] [ctest-options] [other arguments...]
ctest-options and other arguments are passed to ctest.
The list of the testcases to be executed is built from --testlist argument
and a filter on the labels (taken from the .export files).
The sequential label is automatically added for a sequential version.
To show the list of labels, use:
bin/run_ctest --print-labels
Note
Difference from ctest: all values passed to -L option are sorted and
joined as a unique regular expression.
Example:
Using:
bin/run_ctest -L verification -L ci -Nthe ctest command will be:
ctest -N -j 6 -L 'ci.*verification'
See bin/run_ctest --help for the available options.
run — Main classes for execution¶
This module defines the objects that prepare the working directory, copy the data files, execute code_aster and copy the result files.
- run_aster.run.create_temporary_dir(dir=None)[source]¶
Create a temporary directory.
- Returns:
Path of the directory.
- Return type:
str
- class run_aster.run.RunAster(export, test=False, tee=False, output=None, interactive=False, exectool=None, savedb=None, proc0id=0)[source]¶
Bases:
objectExecute code_aster from a .export file.
- Parameters:
export (Export) – Export object defining the calculation.
- classmethod factory(export, test=False, env=False, tee=False, output=None, interactive=False, exectool=None, savedb=None, proc0id=0)[source]¶
Return a RunAster object from an Export object.
- Parameters:
export (Export) – Export object defining the calculation.
test (bool) – for a testcase,
env (bool) – to only prepare the working directory and show command lines to be run,
tee (bool) – to follow execution output,
output (str) – Path to redirect stdout.
interactive (bool) – to keep Python interpreter active.
exectool (str) – command that preceeds code_aster command line.
savedb (bool) – tell if the database should be saved.
proc0id (int) – id of the process that replaces the proc #0.
- __init__(export, test=False, tee=False, output=None, interactive=False, exectool=None, savedb=None, proc0id=0)[source]¶
- execute(workdir)[source]¶
Execution in a working directory.
- Parameters:
workdir (str) – Working directory.
- Returns:
Status object.
- Return type:
- _execute()[source]¶
Execution in the current working directory.
- Returns:
Status object.
- Return type:
- _exec_one(comm, timeout)[source]¶
Show instructions for a command file.
- Parameters:
comm (str) – Command file name.
timeout (float) – Remaining time.
- Returns:
Status object.
- Return type:
- _get_cmdline_exec(commfile, idx)[source]¶
Build the command line really executed, without redirection.
- Parameters:
commfile (str) – Command file name.
idx (int) – Index of execution.
- Returns:
List of command line arguments, without redirection.
- Return type:
list[str]
- _get_cmdline(idx, commfile, timeout)[source]¶
Build the command line.
- Parameters:
idx (int) – Index of execution.
commfile (str) – Command file name.
timeout (float) – Remaining time.
- Returns:
List of command line arguments.
- Return type:
list[str]
- _get_status(exitcode)[source]¶
Get the execution status.
- Parameters:
exitcode (int) – Return code.
- Returns:
Status object.
- Return type:
- ending_execution(results_saved)[source]¶
Post execution phase : copying results, cleanup…
- Parameters:
results_saved (bool) – True if execution did not abort and may have created results, False otherwise.
- class run_aster.run.RunOnlyEnv(*args, **kwargs)[source]¶
Bases:
RunAsterPrepare a working directory for a manual execution.
- Parameters:
export (Export) – Export object defining the calculation.
- run_aster.run.get_procid()[source]¶
Return the identifier of the current process.
- Returns:
Process ID, -1 if a parallel version is not run under mpiexec/srun.
- Return type:
int
- run_aster.run.get_nbcores()[source]¶
Return the number of available cores.
- Returns:
Number of cores.
- Return type:
int
- run_aster.run.set_num_threads(value)[source]¶
Define the number of threads to be used by OpenMP, MKL and OpenBLAS.
- Parameters:
value (int) – Maximum number of threads.
- run_aster.run.copy_datafiles(files, verbose=True)[source]¶
Copy data files into the working directory.
- Parameters:
files (list[File]) – List of File objects.
verbose (bool) – Verbosity.
- run_aster.run.copy_resultfiles(files, copybase, test=False)[source]¶
Copy result files from the working directory.
- Parameters:
files (list[File]) – List of File objects.
copybase (bool) – Tell if result databases will be copied.
test (bool, optional) – True for a testcase, False for a study.
config — Configuration of the version¶
The Config object gives access to the configuration parameters
of the installed version.
These parameters are usually set during the waf configure step and are
stored in a YAML file (or JSON for compatibility).
The configuration file is installed in
<installation-prefix>/share/aster/config.yaml.
It contains version parameters.
The list of the supported version parameters are (with their type):
version_tag: str - version number
version_sha1: str - sha1 of the revision
tmpdir: str - temporary directory used for execution
addmem: int - memory added to the memory limit found from export
parallel: bool - true for a parallel version
python: str - Python interpreter
python_interactive: str - Python interpreter for interactive executions
python_interactive_is_wrapped: bool - Tell of Python for interactive sessions is a wrapper.
mpiexec: str - mpiexec/srun command line with arguments
mpi_get_rank: str - command line to get the mpi rank
only-proc0: bool - true to limit output to proc #0, false to show all
require_mpiexec: bool - tell if mpiexec/srun is required even with one process
use_srun: bool - true if processes are started with srun
FC: str - fortran compiler
FCFLAGS: list[str] - flags for fortran compiler
exectool: dict[str] - command lines for execution wrappers
outputdir: str - output directory for ``waf test`` and derivated
All these parameters are set during the configure step of the installation.
They can be set during the configure step using environment variables named
CONFIG_PARAMETERS_<parameter-name>.
Note
mpiexec command line needs these variables mpi_nbcpu and program
following the Python Format String Syntax. For example:
mpiexec -n {mpi_nbcpu} --tag-output {program}
These version parameters can be overridden by a user file:
$HOME/.config/aster/config.yaml.
The user can override these parameters depending on the server name and/or the version using filters. A server is defined by its name, a version by its path.
Parameters are read from the installation directory
(share/aster/config.yaml), then, from the user file (from .config/aster
directory), per-server configurations are read in the order they are listed
and finally, the per-version configurations are evaluated.
Example of $HOME/.config/aster/config.yaml (for this example only tmpdir
is set in different cases):
server:
- name: eocn*
config:
tmpdir: /tmp_for_eocn_nodes
version:
- path: '*/install/14*'
config:
tmpdir: /tmp_for_v14
- path: '*/dev/codeaster/install/*'
config:
tmpdir: /tmp_for_development_version
What is the value for tmpdir on a cluster node named eocn123 running
the version installed in the /projets/aster/install/14.4/mpi?
First,
tmpdiris read from/projets/aster/install/14.4/mpi/share/aster/config.yaml.Does
eocn123match"*"? Yes, so use/tmp_for_all_servers.Does
eocn123match"eocn*"? Yes, so use/tmp_for_eocn_nodes.Does
/projets/aster/install/14.4/mpimatch"*/install/14*"? Yes, so use/tmp_for_v14.Does
/projets/aster/install/14.4/mpimatch"*/dev/codeaster/install/*"? No.Finally, the working directory will be created in
/tmp_for_v14.
Each block config can override one or more parameter already defined in
config.yaml.
An execution wrapper is a tool, for example a debugger or valgrind, that
can preceed the executed command line.
Example of $HOME/.config/aster/config.yaml:
server:
- name: '*'
config:
exectool:
valgrind: valgrind --tool=memcheck --leak-check=full --error-limit=no --track-origins=yes
This valgrind command line is actually defined by default in the configuration
file of the installed version and it is callable with run_aster --valgrind ....
Another one is also defined by default to wrap gdb execution:
run_aster --gdb ....
- class run_aster.config.ConfigurationStore[source]¶
Bases:
StoreObject that stores settings for a version.
- class run_aster.config.Config(mainfcfg)[source]¶
Bases:
objectConfiguration parameters.
- Parameters:
mainfcfg (str) – File name of the configuration file.
- property storage¶
Attribute that holds the ‘storage’ property.
- Type:
dict
- load_one(cfgfile, main=False)[source]¶
Load cfgfile.
- Parameters:
cfgfile (str) – File name of the configuration file.
main (bool) – True for the configuration file installed for this version, False for user configuration file.
- import_dict(content, with_sections)[source]¶
Set the configuration parameters from a dict.
- Parameters:
content (dict) – file content
with_sections (bool) – True if it contains ‘server’ and/or ‘version’ subsections, False if it directly contains the version parameters.
export — Export file object¶
The Export object parses .export files and provides
getters and setters onto the parameters.
This object contains File and ExportParameter objects.
The arguments of the code_aster command line are stored in a special
ExportParameter object.
The syntax of a .export file is very simple:
P parameter-name parameter-value
A args --arg1 --arg2
F-or-R type path-to-compressed-input-output-file DRC unit
P for parameters, supported parameters are (with their type):
actions: list[str] - for GUI, "make_env" for "--env"
expected_diag: list[str] - for testcases that may fail
hide-command: bool - do not show the command file before execution
interact: bool - for GUI, same as "--interactive"
memory_limit: float - memory limit in MB
mpi_nbcpu: int - number of MPI processes
ncpus: int - number of threads (per MPI process)
no-mpi: bool - start without mpiexec/srun (for some testcases)
time_limit: float - time limit is seconds
A is a special parameter that stores command line arguments passed to the
code_aster command file.
F-or-R: F for files, R for directories.
DRC: one or more characters meaning D data file, R result file,
C for compressed (using gzip).
Example (from sslv139a testcase):
P time_limit 60
P memory_limit 512
P testlist submit ci verification sequential
F comm sslv139a.comm D 1
F datg sslv139a.datg D 16
F mmed sslv139a.mmed D 20
Paths are relative to the parent directory of the .export file
(sslv139a.comm is in the same directory as sslv139a.export).
- class run_aster.export.ExportParameter(name)[source]¶
Bases:
AbstractParameterA parameter defined in a Export object.
- name¶
Parameter name.
- Type:
str
- value¶
Value of the parameter.
- Type:
misc
- class run_aster.export.ExportParameterStr(name)[source]¶
Bases:
ExportParameter,ParameterStrA parameter defined in a Export object of type string.
- class run_aster.export.ExportParameterBool(name)[source]¶
Bases:
ExportParameter,ParameterBoolA parameter defined in a Export object of type boolean.
- class run_aster.export.ExportParameterInt(name)[source]¶
Bases:
ExportParameter,ParameterIntA parameter defined in a Export object of type integer.
- class run_aster.export.ExportParameterFloat(name)[source]¶
Bases:
ExportParameter,ParameterFloatA parameter defined in a Export object of type float.
- class run_aster.export.ExportParameterListStr(name)[source]¶
Bases:
ExportParameter,ParameterListStrA parameter defined in a Export object of type list of strings.
- class run_aster.export.File(path, filetype='libr', unit=0, isdir=False, data=False, resu=False, compr=False)[source]¶
Bases:
objectA file or directory defined in a Export object.
- Parameters:
path (str) – File or directory path.
filetype (str, optional) – File type (“comm”, “libr”, “nom”, “repe”…).
unit (int, optional) – Logical unit number.
isdir (bool, optional) – True for a directory, False for a file. If the file or directory exists, it is automatically set.
data (bool, optional) – True if it is an input. If neither data or resu is set, data is automatically set to True.
resu (bool, optional) – True if it is an output.
compr (bool, optional) – True if it is compressed.
- property path¶
Attribute that holds the ‘path’ property.
- Type:
str
- property filetype¶
Attribute that holds the ‘filetype’ property.
- Type:
str
- property is_tests_data¶
Attribute that tells if this is a data file for testcase. It is taken from a specific directory.
- Type:
bool
- property unit¶
Attribute that holds the ‘unit’ property.
- Type:
int
- property compr¶
Attribute that holds the ‘compr’ property.
- Type:
bool
- property isdir¶
Attribute that holds the ‘isdir’ property.
- Type:
bool
- property data¶
Attribute that holds the ‘data’ property.
- Type:
bool
- property resu¶
Attribute that holds the ‘resu’ property.
- Type:
bool
- property as_argument¶
String to be passed on command_line
- Type:
str
- class run_aster.export.Export(filename=None, from_string=None, test=False, check=True)[source]¶
Bases:
StoreThis object represents a .export file.
- Parameters:
export_file (str, optional) – File name of the export file.
from_string (str, optional) – Export content as string.
test (bool, optional) – True for a testcase, False for a study.
check (bool, optional) – True to automatically check the consistency. False if it will be run manually.
- property filename¶
Path to the export file or None if initialized from a text.
- Type:
str
- files_of_type(typ)[source]¶
Return the list of files of the given type.
- Parameters:
typ (str) – Expected type.
- Returns:
List of output File objects.
- Return type:
list[File]
- remove_file(fileobj)[source]¶
Remove a File object.
- Parameters:
fileobj (File) – File object to be removed.
- import_file_argument(line)[source]¶
Add a File object by decoding a line as formatted by File.as_argument.
- Parameters:
line (str) – Line as formatted by File.as_argument
- parse(check)[source]¶
Parse the export content.
- Parameters:
check (bool) – Check the consistency of the export file.
- set_argument(opts)[source]¶
Add command line arguments. The caller must check if the options are not already present or if they can appear several times.
- Parameters:
opts (list[str]) – List of arguments (for example: “-c”, “–abort”, “–memory=1024”…).
- check()[source]¶
Check consistency, fill arguments from parameter, add arguments that replace deprecated ones…
- __repr__()[source]¶
Return a representation of the Export object.
- Returns:
Representation of the content.
- Return type:
str
- write_to(filename)[source]¶
Write the content to a file.
- Parameters:
filename (str) – Destination file.
- property args¶
Return the arguments list.
- Returns:
List of arguments.
- Return type:
list[str]
- get_argument_value(key, typ)[source]¶
Return the value of a command line argument.
- Parameters:
key (str) – Argument name.
typ (str|int|float|bool) – Type of expected value.
- remove_args(key, add)[source]¶
Remove a command line argument.
- Parameters:
key (str) – Argument name.
add (int) – Number of additional argument to remove.
- run_aster.export.split_export(export)[source]¶
Return a different Export object for each ‘comm’ file.
- Returns:
List of Export objects.
- Return type:
list[Export]
settings — Objects to deal with settings¶
Store is a general storage object that holds various kinds
of settings as typed parameters.
The base object is the AbstractParameter object from which are
derivated objects to store values of type str, int, float, bool and
list of str.
- class run_aster.settings.AbstractParameter(name)[source]¶
Bases:
objectAn abstract parameter that must be subclassed to hold a typed value.
- property name¶
Parameter name.
- Type:
str
- property value¶
Value of the parameter.
- Type:
misc
- class run_aster.settings.ParameterStr(name)[source]¶
Bases:
AbstractParameterA parameter defined in a Export object of type string.
It may use environment variable “${VAR}”, substitution is only done once when the value is assigned.
- class run_aster.settings.VarMixin[source]¶
Bases:
objectMixin class for a parameter that may be overridden by environment.
- class run_aster.settings.ParameterVarStr(name)[source]¶
Bases:
VarMixin,ParameterStrA parameter defined in a Export object of type string that may be overridden by an environment variable.
- class run_aster.settings.ParameterBool(name)[source]¶
Bases:
AbstractParameterA parameter defined in a Export object of type boolean.
- class run_aster.settings.ParameterInt(name)[source]¶
Bases:
AbstractParameterA parameter defined in a Export object of type integer.
- class run_aster.settings.ParameterFloat(name)[source]¶
Bases:
AbstractParameterA parameter defined in a Export object of type float.
- class run_aster.settings.ParameterListStr(name)[source]¶
Bases:
AbstractParameterA parameter defined in a Export object of type list of strings.
- class run_aster.settings.ParameterVarListStr(name)[source]¶
Bases:
VarMixin,ParameterListStrA parameter defined in a Export object of type list of strings that may be overridden by an environment variable.
- class run_aster.settings.ParameterDictStr(name)[source]¶
Bases:
AbstractParameterA parameter defined in a Export object of type dict of strings.
- class run_aster.settings.Store[source]¶
Bases:
objectA base object to store some settings.
This class must be subclassed and a
_new_paramclass method must be added to make set() method usable.- has_param(name)[source]¶
Tell if name is a known parameter.
- Parameters:
name (str) – Parameter name.
- Returns:
True it the parameter is defined, False otherwise.
- Return type:
bool
- get_param(name)[source]¶
Return a parameter.
- Parameters:
name (str) – Parameter name.
- Returns:
Parameter or None if the parameter does not exist.
- Return type:
misc
- get(name, default=None)[source]¶
Return a parameter value.
- Parameters:
name (str) – Parameter name.
default (misc, optional) – Default value if the parameter does not exist.
- Returns:
Parameter value.
- Return type:
misc
status — Extract the state of a code_aster execution¶
The execution state is computed from the exit code of the execution (null if the execution ends normally or !=0 otherwise) and the content of the output of the execution (from .mess file).
For testcases, the execution may end normally but with a state not Ok if there is no TEST_RESU or if it is NOOK.
- class run_aster.status.Status(state=0, exitcode=-1)[source]¶
Bases:
objectObject that represents the status of an execution.
- property state¶
State of the execution.
- Type:
- property diag¶
State of the execution as string (diagnostic).
- Type:
str
- property exitcode¶
Exit code.
- Type:
int
- property times¶
List of 4 values (cpu, sys, tot, elapsed time).
- Type:
list[float]
- is_completed()[source]¶
Tell if the calculation was completed (the result databases should be available.
- Returns:
True if the calculation was completed, False otherwise.
- Return type:
bool
- results_saved()[source]¶
Tell if the result databases should be saved (the calculation is completed or stopped properly).
- Returns:
True if the calculation was completed, False otherwise.
- Return type:
bool
- update(other)[source]¶
Update the status with a new one (from a following execution). It keeps the effective state, the worst exit code and the sum of elapsed times.
- Parameters:
other (Status) – Status of a following execution.
- class run_aster.status.StateOptions(value)[source]¶
Bases:
IntFlagEnumerator for result state.
- Warn¶
Execution emitted a warning.
- Nook¶
Invalid testcase execution (incorrect value).
- NoTest¶
Invalid testcase execution (no value checked).
- Ok¶
Execution was finished successfully.
- CpuLimit¶
Execution ended with cpu time error.
- Convergence¶
Execution ended with no convergence error.
- Memory¶
Execution ended with a memory error.
- Except¶
Execution ended with an exception.
- Syntax¶
Execution ended with a syntax error.
- Fatal¶
Execution ended with a fatal error.
- Abort¶
Execution ended abnormally.
- Completed¶
Execution run up to the end, the results files should be available.
- Error¶
Execution failed, results files may be missing or corrupted.
- run_aster.status.get_status(exitcode, output, test=False)[source]¶
Return the diagnostic after a Code_Aster execution.
- Parameters:
output (str) – Output file name or content. If the filename does not exist, the string is used as file content.
test (bool, optional) – True for a testcase, False for a study.
- Returns:
Status object.
- Return type:
error_messages — Extract error messages from an execution¶
This module defines functions to extract the error messages from the output file of an execution.
- run_aster.error_messages.search_msg(text, maxlines=100000)[source]¶
Return all messages found in a text.
- Parameters:
text (str) – Output of a code_aster execution.
maxlines (int) – Parse only the last maxlines lines.
- Returns:
Ordered Dict of list of messages, indexed by command identifier.
- Return type:
dict
- run_aster.error_messages._remove_decoration(text)[source]¶
Remove the message decoration.
- Parameters:
text (str) – Text of a message.
- Returns:
Message without its decoration.
- Return type:
str
- run_aster.error_messages._regexp_decoration()[source]¶
Return regular expressions to search for the horizontal and vertical markers of decorated messages
- run_aster.error_messages._add_line_numbers(text)[source]¶
Insert line numbers at the beginning of the log of code_aster execution.
- Parameters:
text (str) – Log (output) of code_aster execution.
command_files — Changing commands files¶
This modules provides some functions that change commands files.
- run_aster.command_files.add_import_commands(text)[source]¶
Add import of code_aster commands if not present.
- Parameters:
text (str) – Text of a command file.
- Returns:
Changed content.
- Return type:
str
- run_aster.command_files.add_coding_line(text)[source]¶
Ensure to have ‘coding’ line at the beginning.
- Parameters:
text (str) – Text of a command file.
- Returns:
Changed content.
- Return type:
str
- run_aster.command_files.stop_at_end(text, last=True)[source]¶
Stop execution for interactive commands instead of calling
FIN().- Parameters:
text (str) – Text of a command file.
last (bool) – Tell if this is the last file to be executed. If False, ‘FIN()’ must be preserved.
- Returns:
Changed content.
- Return type:
str
- run_aster.command_files.file_changed(text, original)[source]¶
Additional modifications when the command file was changed.
- Parameters:
text (str) – Text of a command file.
original (str) – Path of original file.
- Returns:
Changed content.
- Return type:
str
- run_aster.command_files.change_procdir(text)[source]¶
Insert command to change into the ‘proc.N’ directory with N the rank of the MPI process.
- Parameters:
text (str) – Text of a command file.
- Returns:
Changed content.
- Return type:
str
toolbox — Toolbox for the developers¶
Build a shared library from a fortran source file.
- Parameters:
lib (str) – Result library.
src (str) – Fortran source file.
args (list[str]) – Optional arguments passed to the linker.
- Returns:
exit code.
- Return type:
int
utils — Utilities¶
This module provides convenient utilities for files manipulation, system command execution, templates…
- run_aster.utils.copy(src, dst, verbose=False)[source]¶
Copy the file or directory src to the file or directory dst. If src is a file, dst can be an existing directory or the destination file name. If src is a directory and dst is an existing directory, the files will be copied into dst. Parent directory of dst is created if necessary.
If dst specifies a directory, the files will be copied into dst using the base filenames from src.
- Parameters:
src (str) – File or directory to be copied.
dst (str) – Destination.
verbose (bool) – Verbosity.
- run_aster.utils.compress(path, verbose=False)[source]¶
Compress a file or the content of a directory.
- Parameters:
path (str) – File or directory path.
verbose (bool) – Verbosity.
- run_aster.utils.uncompress(path, verbose=False)[source]¶
Decompress a file or the content of a directory.
- Parameters:
path (str) – File or directory path.
verbose (bool) – Verbosity.
- run_aster.utils.make_writable(filename)[source]¶
Force a file to be writable by the current user.
- Parameters:
filename (str) – File name.
- run_aster.utils.run_command(cmd, exitcode_file=None)[source]¶
Execute a command and duplicate output to logfile.
- Parameters:
cmd (list) – Command line arguments.
exitcode_file (str, optional) – Read exit code from this file if it exists.
- Returns:
exit code.
- Return type:
int
- run_aster.utils._waitstatus_to_exitcode(status)[source]¶
Replacement for waitstatus_to_exitcode function added in Python 3.9.
- Parameters:
status (int) – status as returned by os.wait()/os.waitpid().
- Returns:
exit code.
- Return type:
int
- run_aster.utils.cmd_abspath(prog)[source]¶
Return the absolute path of a program as found in PATH.
If prog contains a ‘/’, it is returned unchanged.
- Parameters:
prog (str) – Executable or script.
- Returns:
Absolute path to run prog.
- Return type:
str
- class run_aster.utils.PercTemplate(template)[source]¶
Bases:
TemplateTemplate with ‘%’ as delimiter.
logger — Logging and messages output¶
This module defines a logger object and error functions.
All message outputs should pass by this object.
Probably additional levels should be added to distinguish low-debug messages,
debug messages that may be interesting for the user (equivalent to
INFO=2)…
It might be necessary to refactor it in C++ for better performance and a
global access (no C interface currently)…
- class run_aster.logger.PerLevelFormatter(fmt=None, datefmt=None, style='%', validate=True)[source]¶
Bases:
FormatterFormatter for messages
- class run_aster.logger.PerLevelColorFormatter(fmt=None, datefmt=None, style='%', validate=True)[source]¶
Bases:
PerLevelFormatterFormatter for messages
- class run_aster.logger.HgStreamHandler(stream=None)[source]¶
Bases:
StreamHandlerStreamHandler switching between sys.stdout and sys.stderr like the mercurial ui does
- run_aster.logger.build_logger(level=20, raise_exception=True)[source]¶
Initialize the logger with its handlers.
- Parameters:
level (int) – Logging level.
raise_exception (bool) – If True (default), an exception is raised in case of error.
- Returns:
logger object.
- Return type:
Logger
- run_aster.logger.red(string)¶
Return the colored string
- run_aster.logger.green(string)¶
Return the colored string
- run_aster.logger.blue(string)¶
Return the colored string
- run_aster.logger.magenta(string)¶
Return the colored string
- run_aster.logger.cyan(string)¶
Return the colored string
- run_aster.logger.yellow(string)¶
Return the colored string
- run_aster.logger.grey(string)¶
Return the colored string
timer — Simple timer¶
This module defines the simple timer object to store elapsed times during different steps of an execution.
- class run_aster.timer.Measure(cpu, system, total, elapsed)¶
Bases:
tuple- cpu¶
Alias for field number 0
- elapsed¶
Alias for field number 3
- system¶
Alias for field number 1
- total¶
Alias for field number 2
- class run_aster.timer.Timer(title='Total')[source]¶
Bases:
objectObject to trace the time spent during execution.
- start(title)[source]¶
Start a new timer.
- Parameters:
title (str) – Title, also used as identifier for the timer.
- stop(title=None)[source]¶
Stop a timer. If no timer is provided, it stops the last started one.
- Parameters:
title (str, optional) – Title, also used as identifier for the timer.
- static deltat(start, end)[source]¶
Return a tuple of (cpu, sys, total, elapsed) between start and end.
- Parameters:
start (times_result) – Initial time as return by timer().
end (times_result) – End time.
- Returns:
Tuple of 4 floats: (cpu, system, total, elapsed).
- Return type:
- static add(measure, other)[source]¶
Cumulate two measures.
- Parameters:
measure (Measure) – First measure.
other (Measure) – Second measure, that may be null (None).
ctest2junit — Convert a CTest execution report to JUnit¶
This module converts a report from CTest to JUnit format.
This creates a XML file that can be presented by Continous Integration tools.
- class run_aster.ctest2junit.XUnitReport(resudir, legend='')[source]¶
Bases:
objectRepresents a report to be exported at the xUnit format.
- Parameters:
resudir (str) – Directory containing the result files.
- read_ctest(resudir=None)[source]¶
Read the CTest report.
It reads the list of testcases that passed and that failed from the
CTestCostData.txtfile and extracts detailed informations (error messages, OK/NOOK results) from.messfiles.LastTest.logis also parsed to get the elapsed time of testcases in failure.
- run_aster.ctest2junit.get_state(txt)[source]¶
Extract the test state for a ‘message’ file content.
- Parameters:
txt (str) – ‘.mess’ file content.
- Returns:
Error messages.
- Return type:
str