pyinfra.api.util module

pyinfra.api.util.format_exception(e)
pyinfra.api.util.get_args_kwargs_spec(func)
pyinfra.api.util.get_call_location(frame_offset=1)
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_path(state, filename)
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_kwargs_str(kwargs)
pyinfra.api.util.get_operation_order_from_stack(state)
pyinfra.api.util.get_path_permissions_mode(pathname)

Get the permissions (bits) of a path as an integer.

pyinfra.api.util.get_template(filename_or_io)

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.sha1_hash(string)

Return the SHA1 of the input string.

pyinfra.api.util.try_int(value)