Revision 07f5a62c
b/snf-cyclades-app/synnefo/plankton/management/commands/image-list.py | ||
---|---|---|
32 | 32 |
from optparse import make_option |
33 | 33 |
|
34 | 34 |
from synnefo.webproject.management.utils import pprint_table |
35 |
from synnefo.plankton.backend import ImageBackend
|
|
35 |
from synnefo.plankton.utils import image_backend
|
|
36 | 36 |
|
37 | 37 |
|
38 | 38 |
class Command(BaseCommand): |
... | ... | |
41 | 41 |
make_option( |
42 | 42 |
'--user-id', |
43 | 43 |
dest='userid', |
44 |
default=None, |
|
44 | 45 |
help="List all images available to that user." |
45 | 46 |
" If no user is specified, only public images" |
46 | 47 |
" are displayed."), |
47 | 48 |
) |
48 | 49 |
|
49 | 50 |
def handle(self, **options): |
50 |
userid = options['userid']
|
|
51 |
user = options['userid'] |
|
51 | 52 |
|
52 |
c = ImageBackend(userid) if userid else ImageBackend("")
|
|
53 |
images = c.list()
|
|
54 |
images.sort(key=lambda x: x['created_at'], reverse=True) |
|
53 |
with image_backend(user) as backend:
|
|
54 |
images = backend._list_images(user)
|
|
55 |
images.sort(key=lambda x: x['created_at'], reverse=True)
|
|
55 | 56 |
|
56 | 57 |
headers = ("id", "name", "owner", "public") |
57 | 58 |
table = [] |
Also available in: Unified diff