The glanceclient.common.utils Module

glanceclient.common.utils.arg(*args, **kwargs)
glanceclient.common.utils.ensure_str(text, incoming=None, encoding='utf-8', errors='strict')

Encodes incoming objects using encoding. If incoming is not specified, text is expected to be encoded with current python’s default encoding. (sys.getdefaultencoding)

Parameters:
  • incoming – Text’s current encoding
  • encoding – Expected encoding for text (Default UTF-8)
  • errors – Errors handling policy.
Returns:

text or a bytestring encoding encoded representation of it.

glanceclient.common.utils.ensure_unicode(text, incoming=None, errors='strict')

Decodes incoming objects using incoming if they’re not already unicode.

Parameters:
  • incoming – Text’s current encoding
  • errors – Errors handling policy.
Returns:

text or a unicode incoming encoded representation of it.

glanceclient.common.utils.env(*vars, **kwargs)

Search for the first defined of possibly many env vars

Returns the first environment variable defined in vars, or returns the default defined in kwargs.

glanceclient.common.utils.exit(msg='')
glanceclient.common.utils.find_resource(manager, name_or_id)

Helper for the _find_* methods.

glanceclient.common.utils.import_versioned_module(version, submodule=None)
glanceclient.common.utils.integrity_iter(iter, checksum)

Check image data integrity.

Raises :IOError
glanceclient.common.utils.is_authentication_required(f)

Checks to see if the function requires authentication.

Use the skip_authentication decorator to indicate a caller may skip the authentication step.

glanceclient.common.utils.make_size_human_readable(size)
glanceclient.common.utils.pretty_choice_list(l)
glanceclient.common.utils.print_dict(d)
glanceclient.common.utils.print_list(objs, fields, formatters={})
glanceclient.common.utils.save_image(data, path)

Save an image to the specified path.

Parameters:
  • data – binary data of the image
  • path – path to save the image to
glanceclient.common.utils.skip_authentication(f)

Function decorator used to indicate a caller may be unauthenticated.

glanceclient.common.utils.string_to_bool(arg)

This Page