Please note

This documentation is for an outdated version of Fabric. Please click here to be redirected to the most recent stable version.

Utils

Internal subroutines for e.g. aborting execution with an error message, or performing indenting on multiline output.

fabric.utils.abort(msg)

Abort execution, print msg to stderr and exit with error status (1.)

This function currently makes use of sys.exit, which raises SystemExit. Therefore, it’s possible to detect and recover from inner calls to abort by using except SystemExit or similar.

fabric.utils.indent(text, spaces=4, strip=False)

Return text indented by the given number of spaces.

If text is not a string, it is assumed to be a list of lines and will be joined by \n prior to indenting.

When strip is True, a minimum amount of whitespace is removed from the left-hand side of the given string (so that relative indents are preserved, but otherwise things are left-stripped). This allows you to effectively “normalize” any previous indentation for some inputs.

fabric.utils.warn(msg)

Print warning message, but do not abort execution.

This function honors Fabric’s output controls and will print the given msg to stderr, provided that the warnings output level (which is active by default) is turned on.

Previous topic

Operations

Next topic

Console Output Utilities

This Page