Software Design¶
Class Diagram¶
String Handling¶
Convention is to use plain python strings everywhere. Where needed the strings can be converted to anything else.
Example: junitparser expects byte array objects, so we encode our string right before passing it to junitparser.
Instrument Module¶
- class mlx.warnings.WarningsPlugin(verbose=False, config_file=None, cq_enabled=False)[source]¶
Bases:
object
- activate_checker(checker)[source]¶
Activate additional checkers after initialization
- Parameters:
checker (WarningsChecker) – checker object
- activate_checker_name(name)[source]¶
Activates checker by name
- Parameters:
name (str) – checker name
- Returns:
WarningsChecker – activated checker object, or None when no checker with the given name exists
- check(content)[source]¶
Function for counting the number of warnings in a specific text
- Parameters:
content (str) – The text to parse
- config_parser(config)[source]¶
Parsing configuration dict extracted by previously opened JSON file
- Parameters:
config (dict) – Content of configuration file
- get_checker(name)[source]¶
Get checker by name
- Parameters:
name (str) – checker name
- Returns:
checker object (WarningsChecker)
- return_check_limits(name=None)[source]¶
Function for determining the return value of the script
If the name parameter is set, this function will check (and return) the return value of that checker. If not, this function checks whether the warnings for each registered checker are within the configured limits.
- Parameters:
name (WarningsChecker) – The checker for which to check the return value
- Returns:
int –
- 0 if the amount of warnings is within limits, the count of warnings otherwise
(or 1 in case of a count of 0 warnings)
- return_count(name=None)[source]¶
Getter function for the amount of found warnings
If the name parameter is set, this function will return the amount of warnings found by that checker. If not, the function will return the sum of the warnings found by all registered checkers.
- Parameters:
name (WarningsChecker) – The checker for which to return the amount of warnings (if set)
- Returns:
int – Amount of found warnings
- set_maximum(maximum)[source]¶
Setter function for the maximum amount of warnings
- Parameters:
maximum (int) – maximum amount of warnings allowed
- set_minimum(minimum)[source]¶
Setter function for the minimum amount of warnings
- Parameters:
minimum (int) – minimum amount of warnings allowed
- toggle_printout(printout)[source]¶
Toggle printout of all the parsed content
Useful for command input where we want to print content as well
- Parameters:
printout (bool) – True enables the printout, False provides more silent mode
- mlx.warnings.warnings_command(warnings, cmd)[source]¶
Execute command to obtain input for parsing for warnings
Usually log files are output of the commands. To avoid this additional step this function runs a command instead and parses the stderr and stdout of the command for warnings.
- Parameters:
warnings (WarningsPlugin) – Object for warnings where errors should be logged
cmd (list) – List of commands (str), which should be executed to obtain input for parsing
- Returns:
int – Return value of executed command(s)
- Raises:
OSError – When program is not installed.