Mixins provided by mtrchk.org.momotor.mixin.exec

checklet mixin class mtrchk.org.momotor.mixin.exec.ExecutionMixin

A checklet mixin that provides a method to execute a command with runtime monitoring and limiting

timeLimit option

Maximum time allowed for execution. Can be supplied in hh:mm:ss format, or as seconds

Type:

Any

Required:

False

Multiple:

False

Location:

config, step, recipe

Default:

No default

blockLimit option

Maximum time allowed without any progress (wall clock time). Can be supplied in hh:mm:ss format, or as seconds

Type:

Any

Required:

False

Multiple:

False

Location:

config, step, recipe

Default:

No default

memoryLimit option

Maximum memory usage allowed for execution. Can use IEC or SI units, eg. 1k (for 1000 bytes) or 1KiB (for 1024 bytes)

Type:

Any

Required:

False

Multiple:

False

Location:

config, step, recipe

Default:

No default

processLimit option

Maximum number of child processes

Type:

integer

Required:

False

Multiple:

False

Location:

config, step, recipe

Default:

No default

static format_args(*args)

Format arguments for use with monitored_popen()

Parameters:

args (str | int | float | Path | Iterable[str | int | float | Path]) – arguments to format

Return type:

Sequence[str]

Returns:

formatted arguments

monitored_popen(args, *, default_limits=None, **kwargs)

Executes a command with monitoring. A wrapper around MPopen that sets up limits based on checklet options.

Parameters:
Return type:

MPopen

checklet mixin class mtrchk.org.momotor.mixin.exec.CapturedExecutionMixin

A mixin for checklets that captures the data on stdin/stdout/stderr and provides it as a property.

Subclasses from ExecutionMixin so also provides runtime monitoring and limiting.

timeLimit option

Maximum time allowed for execution. Can be supplied in hh:mm:ss format, or as seconds

Type:

Any

Required:

False

Multiple:

False

Location:

config, step, recipe

Default:

No default

Provided by: ExecutionMixin

blockLimit option

Maximum time allowed without any progress (wall clock time). Can be supplied in hh:mm:ss format, or as seconds

Type:

Any

Required:

False

Multiple:

False

Location:

config, step, recipe

Default:

No default

Provided by: ExecutionMixin

memoryLimit option

Maximum memory usage allowed for execution. Can use IEC or SI units, eg. 1k (for 1000 bytes) or 1KiB (for 1024 bytes)

Type:

Any

Required:

False

Multiple:

False

Location:

config, step, recipe

Default:

No default

Provided by: ExecutionMixin

processLimit option

Maximum number of child processes

Type:

integer

Required:

False

Multiple:

False

Location:

config, step, recipe

Default:

No default

Provided by: ExecutionMixin

stdin option

Content to provide on stdin. Mutually exclusive with the stdin-file-ref option. If neither stdin and stdin-file-ref options are provided, stdin is closed.

Type:

Any

Required:

False

Multiple:

False

Location:

config, step, recipe

Default:

No default

stdin-file-ref option

Reference to a file to provide text on stdin. Mutually exclusive with the stdin option. If neither stdin-file-ref and :momotor:option:.stdin` options are provided, stdin is closed.

The reference is parsed with find_files(), see that method for details.

Type:

Any

Required:

False

Multiple:

False

Location:

config, step, recipe

Default:

No default

input-file-ref option

Reference for file(s) to put in execution tree.

The reference is parsed with find_files(), see that method for details.

Type:

Any

Required:

False

Multiple:

True

All:

False

Location:

config, step, recipe

Default:

No default

input-delay option

Delay (in milliseconds) between sending lines on stdin

Type:

integer

Required:

False

Multiple:

False

Location:

config, step, recipe

Default:

No default

capture-stdio option

Capture the stream on stdin/out/err. When enabled, the checklet outputs a property stdio containing a (json) list of objects. The objects contains entries for I/O on ‘stdin’, ‘stdout’, ‘stderr’ (with key 0, 1 and 2 respectively), and a timestamp in seconds since execution start (with key @)

Type:

boolean

Required:

False

Multiple:

False

Location:

config, step, recipe

Default:

False

stdout-file-class option

Export output produced on stdout to a file with this class

Type:

Any

Required:

False

Multiple:

False

Location:

config, step, recipe

Default:

No default

stderr-file-class option

Export output produced on stderr to a file with this class

Type:

Any

Required:

False

Multiple:

False

Location:

config, step, recipe

Default:

No default

stdouterr-file-class option

Export combined output produced on stdout/stderr combined to a file with this class

Type:

Any

Required:

False

Multiple:

False

Location:

config, step, recipe

Default:

No default

output-file-class option

Export produced or modified files with this class

Type:

Any

Required:

False

Multiple:

False

Location:

config, step, recipe

Default:

No default

pass-on-exitcode option

A comma-separated list of exit codes that should not be considered a failure. Ranges can be indicated as X..Y. This list should include the “0” exit code if it should be a pass. e.g. 0, 1, 100..109 allows exit codes 0, 1 and 100 up to and including 109

Type:

Any

Required:

False

Multiple:

False

Location:

config, step, recipe

Default:

0

fail-on-stderr option

Produce a fail outcome if any (non-whitespace) output is produced on stderr

Type:

boolean

Required:

False

Multiple:

False

Location:

config, step, recipe

Default:

False

report-stdio option

Report stdio.

Either true, false or a (comma or space-seperated) list of streams (in, out, err) to include.

in stream will be formatted bold, out stream will be in regular font and err stream will be in red.

Default: false

Type:

Any

Required:

False

Multiple:

False

Location:

config, step, recipe

Default:

false

truncate-stdout-lines option

Limit for the number of lines captured from stdout.

Can be use IEC or SI units, eg. 1k (for 1000 lines) or 1KiB (for 1024 lines). Default = 5000, hard limit = 100k

Type:

string

Required:

False

Multiple:

False

Location:

config, step, recipe

Default:

No default

truncate-stdout-bytes option

Limit for the number of bytes captured from stdout.

Can be use IEC or SI units, eg. 1k (for 1000 bytes) or 1KiB (for 1024 bytes). Default = 1 MiB, hard limit = 16 MiB

Type:

string

Required:

False

Multiple:

False

Location:

config, step, recipe

Default:

No default

truncate-stderr-lines option

Limit for the number of lines captured from stderr.

Can be use IEC or SI units, eg. 1k (for 1000 lines) or 1KiB (for 1024 lines). Default = 5000, hard limit = 100k

Type:

string

Required:

False

Multiple:

False

Location:

config, step, recipe

Default:

No default

truncate-stderr-bytes option

Limit for the number of bytes captured from stderr. Can be use IEC or SI units, eg. 1k (for 1000 bytes) or 1KiB (for 1024 bytes).

Default = 1 MiB, hard limit = 16 MiB

Type:

string

Required:

False

Multiple:

False

Location:

config, step, recipe

Default:

No default

fail-on-truncation option

Fail if an output is truncated.

Can be a boolean ‘true’ to fail if either stdout or stderr is truncated, ‘false’ to never fail on truncation, or the values ‘stdout’ or ‘stderr’ to only fail if that stream is truncated

Type:

string

Required:

False

Multiple:

False

Location:

config, step, recipe

Default:

false

captured_popen(args, cwd, *, encoding='utf8', errors='replace', default_limits=None, default_run_limits=None, default_capture_limits=None, **kwargs)

Call monitored_popen() providing input from a file to stdin and capturing the output on stdout and stderr.

Parameters:
Return type:

CheckletResult

Returns:

The result of the execution. Can be used as the checklet result, or processed further by the checklet.