From dbfe85da5351a59d29f465aaced8daf07a6d61bd Mon Sep 17 00:00:00 2001 From: Ryan Petrello Date: Wed, 4 Sep 2019 10:33:12 -0400 Subject: [PATCH] cli: fix a -f human formatting bug in py2 if we encounter non-strings in JSON responses, attempt to represent them as JSON, instead of stringify-ing them (in py2, stringify-ing adds `u` markers, which is confusing to users) --- awxkit/awxkit/cli/format.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/awxkit/awxkit/cli/format.py b/awxkit/awxkit/cli/format.py index be1a0e3722..0f593151f8 100644 --- a/awxkit/awxkit/cli/format.py +++ b/awxkit/awxkit/cli/format.py @@ -163,8 +163,8 @@ def format_human(output, fmt): try: return locale.format("%.*f", (0, int(v)), True) except (ValueError, TypeError): - if not isinstance(v, six.text_type): - return str(v) + if isinstance(v, (list, dict)): + return json.dumps(v) return v # calculate the max width of each column