stuffer.core module

class stuffer.core.Action[source]

Bases: stuffer.utils.NaturalReprMixin

Base class for actions to be taken.

Subclasses should override either command() or run(). If command() is overridden, it will get logged to stdout. If run() is overridden, the implementation should provide some form of logging.

command() → Union[str, stuffer.content.DeferStr, List[str]][source]

Shell command to run. Override this or run().

Should either return a list of strings to pass to subprocess.check_output, or a string, in which case shell=True will be passed with subprocess.check_output..

execute() → None[source]

Execute the action, including any prerequisites.

prerequisites()[source]
run() → str[source]

Run the Action command(s).

The default implementation runs the command returned by command().

str
The output of the command
subprocess.CalledProcessError
On execution failure.
static tmp_dir() → pathlib.Path[source]

Directory for temporary file storage, e.g. downloaded files.

class stuffer.core.ActionRegistry[source]

Bases: object

Singleton class to keep track of the created Actions.

classmethod register(action)[source]
classmethod registered()[source]
class stuffer.core.Group[source]

Bases: stuffer.core.Action

Group of multiple actions to be executed.

children() → List[stuffer.core.Action][source]

Returns list of child actions to execute.

run() → None[source]

Run the Action command(s).

The default implementation runs the command returned by command().

str
The output of the command
subprocess.CalledProcessError
On execution failure.
stuffer.core.run_cmd(cmd: List[str], *args, **kwargs)[source]

Run a shell command and return the output.

cmd
List of command and arguments, passed to subprocess.check_output. If a string is passed, shell=True will be added to kwargs.
args
Extra arguments passed to subprocess.check_output
kwargs
Extra keyword arguments passed to subprocess.check_output

The output of the command

subprocess.CalledProcessError
On execution failure.