Revision 9597fc83 snf-astakos-app/astakos/im/management/commands/listservices.py
b/snf-astakos-app/astakos/im/management/commands/listservices.py | ||
---|---|---|
39 | 39 |
|
40 | 40 |
class Command(BaseCommand): |
41 | 41 |
help = "List g" |
42 |
|
|
42 |
|
|
43 | 43 |
option_list = BaseCommand.option_list + ( |
44 | 44 |
make_option('-c', |
45 | 45 |
action='store_true', |
... | ... | |
47 | 47 |
default=False, |
48 | 48 |
help="Use pipes to separate values"), |
49 | 49 |
) |
50 |
|
|
50 |
|
|
51 | 51 |
def handle(self, *args, **options): |
52 | 52 |
if args: |
53 | 53 |
raise CommandError("Command doesn't accept any arguments") |
54 |
|
|
54 |
|
|
55 | 55 |
services = Service.objects.all() |
56 |
|
|
57 |
labels = ('id', 'name', 'url', 'icon') |
|
58 |
columns = (3, 12, 40, 40)
|
|
59 |
|
|
56 |
|
|
57 |
labels = ('id', 'name', 'url', 'auth_token', 'icon')
|
|
58 |
columns = (3, 12, 40, 20, 20)
|
|
59 |
|
|
60 | 60 |
if not options['csv']: |
61 | 61 |
line = ' '.join(l.rjust(w) for l, w in zip(labels, columns)) |
62 | 62 |
self.stdout.write(line + '\n') |
63 | 63 |
sep = '-' * len(line) |
64 | 64 |
self.stdout.write(sep + '\n') |
65 |
|
|
65 |
|
|
66 | 66 |
for service in services: |
67 |
fields = (str(service.id), service.name, service.url, service.icon) |
|
68 |
|
|
67 |
fields = (str(service.id), service.name, service.url, |
|
68 |
service.auth_token, |
|
69 |
service.icon) |
|
70 |
|
|
69 | 71 |
if options['csv']: |
70 | 72 |
line = '|'.join(fields) |
71 | 73 |
else: |
72 | 74 |
line = ' '.join(f.rjust(w) for f, w in zip(fields, columns)) |
73 |
|
|
75 |
|
|
74 | 76 |
self.stdout.write(line.encode('utf8') + '\n') |
Also available in: Unified diff