Check /projects responses for null values.

Some values can be null/None so check for that instead of crashing.

(cherry picked from commit f916e41d00)
(cherry picked from commit 83680d92b0)
This commit is contained in:
Brian C. Lane 2018-07-17 11:51:04 -07:00
parent 5993802bc6
commit de0e5d2b59

View File

@ -65,7 +65,7 @@ def projects_list(socket_path, api_version, args, show_json=False):
return 0 return 0
for proj in result["projects"]: 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("%s: %s" % (k.title(), textwrap.fill(proj[k], subsequent_indent=" " * (len(k)+2))))
print("\n\n") print("\n\n")
@ -96,7 +96,7 @@ def projects_info(socket_path, api_version, args, show_json=False):
return 0 return 0
for proj in result["projects"]: 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("%s: %s" % (k.title(), textwrap.fill(proj[k], subsequent_indent=" " * (len(k)+2))))
print("Builds: ") print("Builds: ")
for build in proj["builds"]: for build in proj["builds"]: