PageRenderTime 166ms CodeModel.GetById 81ms app.highlight 9ms RepoModel.GetById 72ms app.codeStats 0ms

/silverlining/commands/list_images.py

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