From 574dc8393fd1dd44e9e4fca83532e4c99f56633c Mon Sep 17 00:00:00 2001 From: George Kraft Date: Wed, 18 Dec 2013 12:01:01 -0600 Subject: CXMAN-215: Fix handling of error cases in the CLI "sensors" command --- cxmanage_api/cli/__init__.py | 2 +- cxmanage_api/cli/commands/sensor.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cxmanage_api/cli/__init__.py b/cxmanage_api/cli/__init__.py index ea4284a..bb0f2f7 100644 --- a/cxmanage_api/cli/__init__.py +++ b/cxmanage_api/cli/__init__.py @@ -173,7 +173,7 @@ def get_node_strings(args, nodes, justify=False): else: strings = [x.ip_address for x in nodes] - if justify: + if strings and justify: just_size = max(16, max(len(x) for x in strings) + 1) strings = [x.ljust(just_size) for x in strings] diff --git a/cxmanage_api/cli/commands/sensor.py b/cxmanage_api/cli/commands/sensor.py index 51ebe5b..949de6c 100644 --- a/cxmanage_api/cli/commands/sensor.py +++ b/cxmanage_api/cli/commands/sensor.py @@ -61,7 +61,8 @@ def sensor_command(args): sensors[sensor_name].append((node, reading, "")) node_strings = get_node_strings(args, results, justify=True) - jsize = len(node_strings.itervalues().next()) + if node_strings: + jsize = len(node_strings.itervalues().next()) for sensor_name, readings in sensors.iteritems(): print sensor_name -- cgit v1.2.1