list-hosts shouldn't error on empty list

Fixes: https://pagure.io/koji/issue/1470
This commit is contained in:
Tomas Kopecek 2019-05-30 10:04:48 +02:00
parent b122dcd4dc
commit e41d9ca756

View file

@ -2818,7 +2818,10 @@ def anon_handle_list_hosts(goptions, session, args):
for host, [channels] in zip(hosts, session.multiCall()):
host['channels'] = ','.join(sorted([c['name'] for c in channels]))
longest_host = max([len(h['name']) for h in hosts])
if hosts:
longest_host = max([len(h['name']) for h in hosts])
else:
longest_host = 8
if not options.quiet:
hdr = "{hostname:<{longest_host}} Enb Rdy Load/Cap Arches Last Update".format(longest_host=longest_host, hostname='Hostname')
if options.show_channels: