awslimitchecker.utils module¶
-
class
awslimitchecker.utils.StoreKeyValuePair(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)[source]¶ Bases:
argparse.ActionStore key=value options in a dict as {‘key’: ‘value’}.
Supports specifying the option multiple times, but NOT with
nargs.See
Action.-
__init__(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
__module__= 'awslimitchecker.utils'¶
-
-
awslimitchecker.utils._get_dict_value_by_path(d, path)[source]¶ Given a dict (
d) and a list specifying the hierarchical path to a key in that dict (path), return the value at that path or None if it does not exist.Parameters:
-
awslimitchecker.utils._get_latest_version()[source]¶ Attempt to retrieve the latest awslimitchecker version from PyPI, timing out after 4 seconds. If the version can be retrieved and is greater than the currently running version, return it as a string. If the version cannot be retrieved or is not greater than the currently running version, return None.
This function MUST not ever raise an exception.
Returns: latest version from PyPI, if newer than current version Return type: str or None
-
awslimitchecker.utils._set_dict_value_by_path(d, val, path)[source]¶ Given a dict (
d), a value (val), and a list specifying the hierarchical path to a key in that dict (path), set the value indatpathtoval.Parameters: Raises: TypeError if the path is too short
Returns: the modified dict
-
awslimitchecker.utils.dict2cols(d, spaces=2, separator=' ')[source]¶ Take a dict of string keys and string values, and return a string with them formatted as two columns separated by at least
spacesnumber ofseparatorcharacters.Parameters:
-
awslimitchecker.utils.issue_string_tuple(service_name, limit, crits, warns, colorize=True)[source]¶ Return a 2-tuple of key (service/limit name)/value (usage) strings describing a limit that has crossed its threshold.
Parameters: - service_name (str) – the name of the service
- limit (
AwsLimit) – the Limit this relates to - crits – the specific usage values that crossed the critical threshold
- crits – the specific usage values that crossed the warning threshold
- colorize (bool) – whether or not to colorize output; passed through to
color_output().
Returns: 2-tuple of strings describing crossed thresholds, first describing the service and limit name and second listing the limit and usage
Return type:
-
awslimitchecker.utils.paginate_dict(function_ref, *argv, **kwargs)[source]¶ Paginate through a query that returns a dict result, and return the combined result.
Note that this function requires some special kwargs to be passed in:
- __alc_marker_path__ - The dictionary path to the Marker for the next result set. If this path does not exist, the raw result will be returned.
- __alc_data_path__ - The dictionary path to the list containing the query results. This will be updated with the results of subsequent queries.
- __alc_marker_param__ - The parameter name to pass to
function_refwith the marker value.
These paths should be lists, in a form usable by
_get_dict_value_by_path().Parameters: