From e41d9ca756740e9874302e3fddcfd0291564f5dc Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: May 30 2019 08:05:33 +0000 Subject: list-hosts shouldn't error on empty list Fixes: https://pagure.io/koji/issue/1470 --- diff --git a/cli/koji_cli/commands.py b/cli/koji_cli/commands.py index 018428a..1c6d69c 100644 --- a/cli/koji_cli/commands.py +++ b/cli/koji_cli/commands.py @@ -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: