PageRenderTime 23ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/silverlining/commands/list_images.py

https://bitbucket.org/ianb/silverlining/
Python | 19 lines | 16 code | 2 blank | 1 comment | 6 complexity | f36d37b095b5cdc4e7241b9c66b1fdbe MD5 | raw file
Possible License(s): GPL-2.0
  1. """List available images"""
  2. def command_list_images(config):
  3. images = config.cached_images(expiration=0)
  4. try:
  5. default_image = config.select_image(images=images)
  6. except LookupError:
  7. default_image = None
  8. if not default_image:
  9. config.logger.info(
  10. '[%s] has no default image' % (
  11. config['section_name']))
  12. for image in images:
  13. if image is default_image:
  14. default = '**default**'
  15. else:
  16. default = ''
  17. config.logger.notify('%6s %s %s' % (image.id, image.name, default))