From 0b781536b26e57903b297d4d4e7806e4a051a532 Mon Sep 17 00:00:00 2001 From: John Griffith Date: Thu, 11 Apr 2013 19:17:01 -0600 Subject: [PATCH] Don't print the empty table on list operations. Changes to strutils.safe_encode cause the empty table to be printed out when no objects are actually retrieved. This patch just adds a check of the object list length before calling strutils.safe_encode, if the length is NOT > 0 we just return like we used to. Change-Id: I57930b5210c975baa7c4510fcf82b17157e17788 --- cinderclient/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cinderclient/utils.py b/cinderclient/utils.py index f9c65661d..558c29221 100644 --- a/cinderclient/utils.py +++ b/cinderclient/utils.py @@ -143,7 +143,8 @@ def print_list(objs, fields, formatters={}): row.append(data) pt.add_row(row) - print strutils.safe_encode(pt.get_string(sortby=fields[0])) + if len(objs) > 0: + print strutils.safe_encode(pt.get_string(sortby=fields[0])) def print_dict(d, property="Property"):