Common¶
- class narrenschiff.modules.common.NarrenschiffModule(command)[source]¶
Abstract class/Interface for the module classes. A module must inherit from this class.
- Variables
DRY_RUN_FLAG –
int
The subprocess module does not have a way of indicating whether a command was run with dry run or not, since that is the responsibility of
narrenschiff.modules.common.NarrenschiffModule.execute()
method. If module or subcommand of module is not supporting dry run, thanDRY_RUN_FLAG
is a reserved return code (rc) that indicates that program should not exit, and output should be printed in special color (blue).- abstract property cmd¶
Get command that module needs to execute later.
- Returns
Full command with all parameters
- Return type
str
- property dry_run¶
Return a dry run flag.
- Returns
--dry-run
string- Return type
str
In general most commands use
--dry-run
so there is no need to override this. However, there are exceptions for some commands where this flag is differently named. This property offers extensibility to the modules that may use different flag.
- abstract dry_run_supported(cmd)[source]¶
Check if command supports –dry-run.
- Parameters
cmd (
str
) – Command that module should execute- Returns
Boolean indicating whether command supports dry run
- Return type
bool
- echo(output, rc)[source]¶
Print output to console, and exit if return code is different from 0.
- Parameters
output (
str
) – stdout or stderr of a processrc (
int
) – Return code of the process
- Returns
Void
- Return type
None