diff options
author | George Kraft <george.kraft@calxeda.com> | 2013-12-18 12:01:01 -0600 |
---|---|---|
committer | George Kraft <george.kraft@calxeda.com> | 2013-12-18 12:01:01 -0600 |
commit | 574dc8393fd1dd44e9e4fca83532e4c99f56633c (patch) | |
tree | 10ee6bf297f223f8f11204e749967926e7d38059 | |
parent | b97e1747ecbdbc4d6780642075ca22b3a16076e6 (diff) | |
download | cxmanage-574dc8393fd1dd44e9e4fca83532e4c99f56633c.tar.gz |
CXMAN-215: Fix handling of error cases in the CLI "sensors" command
-rw-r--r-- | cxmanage_api/cli/__init__.py | 2 | ||||
-rw-r--r-- | 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 |