aboutsummaryrefslogtreecommitdiffstats
path: root/sb_builder/fmt.py
diff options
context:
space:
mode:
Diffstat (limited to 'sb_builder/fmt.py')
-rw-r--r--sb_builder/fmt.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/sb_builder/fmt.py b/sb_builder/fmt.py
index 55a2d0d..5c50628 100644
--- a/sb_builder/fmt.py
+++ b/sb_builder/fmt.py
@@ -54,6 +54,16 @@ def job_title(j):
return " ".join([j["kind"], *j["args"]])
+def outcome(j):
+ """How an ended job went, as a sentence for its notification."""
+ took = fmt_duration(j["end"] - j["start"]) if "end" in j and "start" in j else None
+ after = f" after {took}" if took else ""
+ return {"ok": f"Succeeded in {took}" if took else "Succeeded",
+ "failed": f"Failed with exit code {j.get('exit', '?')}{after}",
+ "killed": f"Killed{after}",
+ "lost": "Lost: its runner died (killed, crashed or the VM rebooted)"}[j["status"]]
+
+
def describe(j):
"""One-line job summary: icon, kind and args, start time, duration."""
dur = None if "start" not in j else j.get("end", time.time()) - j["start"]