diff options
author | Rob Austein <sra@hactrn.net> | 2012-07-06 05:14:34 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2012-07-06 05:14:34 +0000 |
commit | 617838817ef21db22f8699ab126e41f6ba090a02 (patch) | |
tree | 4aeb9729ecb50a98822becba1a60c09e8d6dd986 /rcynic | |
parent | 1886c9cab2b2420ca2319315d9641b0933e71fcf (diff) |
Handle empty hostname list.
svn path=/trunk/; revision=4585
Diffstat (limited to 'rcynic')
-rw-r--r-- | rcynic/rcynic-text.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/rcynic/rcynic-text.py b/rcynic/rcynic-text.py index 09797cfa..6757e6e2 100644 --- a/rcynic/rcynic-text.py +++ b/rcynic/rcynic-text.py @@ -84,7 +84,7 @@ class Session(object): def show(self): visible = [label for label in self.labels if label.visible] hostnames = sorted(hostname for hostname in self.hosts if hostname is not None) - hostwidth = max(len(hostname) for hostname in hostnames) + hostwidth = max(len(hostname) for hostname in hostnames + ["Hostname"]) separator = "+-%s-+-%s-+" % ( "-" * hostwidth, "-+-".join("-" * label.width for label in visible)) @@ -98,7 +98,8 @@ class Session(object): print "| %s |%s|" % ( hostname.ljust(hostwidth), "|".join(self.hosts[hostname].total(label) for label in visible)) - print separator + if hostnames: + print separator print "| %s |%s|" % ( "Total".ljust(hostwidth), "|".join(label.total for label in visible)) |