pyinfra.api.util module

class pyinfra.api.util.FallbackDict(*datas)

Bases: object

Combines multiple AttrData’s to search for attributes.

dict()
override_datas = None
pyinfra.api.util.extract_callable_datas(datas)
pyinfra.api.util.format_exception(e)
pyinfra.api.util.get_arg_value(state, host, arg)

This functions is deprecated.

pyinfra.api.util.get_call_location()
pyinfra.api.util.get_caller_frameinfo(frame_offset=0)
class pyinfra.api.util.get_file_io(filename_or_io, mode='rb')

Bases: object

Given either a filename or an existing IO object, this context processor will open and close filenames, and leave IO objects alone.

property cache_key
close = False
pyinfra.api.util.get_file_sha1(filename_or_io)

Calculates the SHA1 of a file or file object using a buffer to handle larger files.

pyinfra.api.util.get_template(filename_or_string, is_string=False)

Gets a jinja2 Template object for the input filename or string, with caching based on the filename of the template, or the SHA1 of the input string.

pyinfra.api.util.log_error_or_warning(host, ignore_errors, description='')
pyinfra.api.util.log_host_command_error(host, e, timeout=0)
pyinfra.api.util.make_hash(obj)

Make a hash from an arbitrary nested dictionary, list, tuple or set, used to generate ID’s for operations based on their name & arguments.

pyinfra.api.util.memoize(func)
pyinfra.api.util.print_host_combined_output(host, combined_output_lines)
pyinfra.api.util.read_buffer(type_, io, output_queue, print_output=False, print_func=None)

Reads a file-like buffer object into lines and optionally prints the output.

pyinfra.api.util.sha1_hash(string)

Return the SHA1 of the input string.

pyinfra.api.util.show_get_arg_value_warning()
pyinfra.api.util.try_int(value)
pyinfra.api.util.underscore(name)

Transform CamelCase -> snake_case.

pyinfra.api.util.unroll_generators(generator)

Take a generator and unroll any sub-generators recursively. This is essentially a Python 2 way of doing yield from in Python 3 (given iterating the entire thing).