manheim_c7n_tools.utils module

manheim_c7n_tools.utils.assume_role(config)[source]

Call sts:AssumeRole (via boto3) to assume the role specified by the configuration. Export the resulting credentials as environment variables for the current process.

The configuration is taken from the assume_role section of the config.

Parameters:config (ManheimConfig) – ManheimConfig object containing assume_role configuration
manheim_c7n_tools.utils.bold(s)[source]

Return the given string (s) surrounded by the ANSI escape codes to print it in bold. :param s: string to console format as bold :type s: str :returns: s surrounded by ANSI color escapes for green text :rtype: str

manheim_c7n_tools.utils.git_html_url()[source]

Run git config remote.origin.url in the current directory. Assuming it works, return the HTML URL for the repository (assumes github.com or github enterprise).

Returns:repository HTML base URL
Return type:str
Raises:RuntimeError if the command fails or the URL cannot be parsed
manheim_c7n_tools.utils.green(s)[source]

Return the given string (s) surrounded by the ANSI escape codes to print it in green. :param s: string to console-color green :type s: str :returns: s surrounded by ANSI color escapes for green text :rtype: str

manheim_c7n_tools.utils.red(s)[source]

Return the given string (s) surrounded by the ANSI escape codes to print it in red. :param s: string to console-color red :type s: str :returns: s surrounded by ANSI color escapes for red text :rtype: str

manheim_c7n_tools.utils.set_log_debug(log)[source]

set log level to DEBUG, and debug-level output format

Parameters:log (logging.Logger) – the logger to set level and format on
manheim_c7n_tools.utils.set_log_info(log)[source]

set log level to INFO with appropriate format

Parameters:log (logging.Logger) – the logger to set level and format on
manheim_c7n_tools.utils.set_log_level_format(log, level, format)[source]

Set log level and format.

Parameters:
  • log (logging.Logger) – the logger to set level and format on
  • level (int) – logging level; see the logging constants.
  • format (str) – logging formatter format string