only print job status for some status values

This commit is contained in:
Siddharth Agrawal 2022-10-18 17:59:58 +05:30
parent a86e5876eb
commit c99a1c5fb5

View File

@ -30,10 +30,10 @@ def get_resp_items(resp):
def get_status_text(status): def get_status_text(status):
if status == "success": if status == "success":
return COLORS.FG.green + "" + COLORS.reset return COLORS.FG.green + "" + COLORS.reset
elif status in ("running", "not_run", "retried", "queued"): elif status in ("running", "not_run", "retried"):
return COLORS.FG.yellow + "·" + COLORS.reset return COLORS.FG.yellow + "" + COLORS.reset
else: else:
return COLORS.FG.red + "˟" + COLORS.reset return COLORS.FG.red + "" + COLORS.reset
if not org_slug or len(args) != 3: if not org_slug or len(args) != 3:
@ -64,8 +64,10 @@ jobs = get_resp_items(response)
for job in jobs: for job in jobs:
status = job["status"] status = job["status"]
name = job["name"] if status in ("success", "running", "failed", "retried", "timedout",
project_slug = job["project_slug"] "on_hold", "canceled", "terminated_unknown"):
job_number = job["job_number"] name = job["name"]
url = f"https://circleci.com/{project_slug}/{job_number}" project_slug = job["project_slug"]
print("{} {:<50} {}".format(get_status_text(status), name, url)) job_number = job["job_number"]
url = f"https://circleci.com/{project_slug}/{job_number}"
print("{} {:<50} {}".format(get_status_text(status), name, url))