From de0e5d2b59e7f119a5699e9573eb2872357d3c3b Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Tue, 17 Jul 2018 11:51:04 -0700 Subject: [PATCH] Check /projects responses for null values. Some values can be null/None so check for that instead of crashing. (cherry picked from commit f916e41d0039821a757f3617593e23fc33c5d856) (cherry picked from commit 83680d92b049b73c3a3c1c85efa461666c71f00f) --- src/composer/cli/projects.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/composer/cli/projects.py b/src/composer/cli/projects.py index 31b20418..ca452884 100644 --- a/src/composer/cli/projects.py +++ b/src/composer/cli/projects.py @@ -65,7 +65,7 @@ def projects_list(socket_path, api_version, args, show_json=False): return 0 for proj in result["projects"]: - for k in ["name", "summary", "homepage", "description"]: + for k in [field for field in ("name", "summary", "homepage", "description") if proj[field]]: print("%s: %s" % (k.title(), textwrap.fill(proj[k], subsequent_indent=" " * (len(k)+2)))) print("\n\n") @@ -96,7 +96,7 @@ def projects_info(socket_path, api_version, args, show_json=False): return 0 for proj in result["projects"]: - for k in ["name", "summary", "homepage", "description"]: + for k in [field for field in ("name", "summary", "homepage", "description") if proj[field]]: print("%s: %s" % (k.title(), textwrap.fill(proj[k], subsequent_indent=" " * (len(k)+2)))) print("Builds: ") for build in proj["builds"]: