From 32201a3d505b6b78da7ba15c2bb77093d52ec735 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Tue, 20 Oct 2026 19:21:24 +0200 Subject: Notifications: icon per outcome, body says how the job went Title is the job (kind and args), body the outcome: succeeded in, failed with exit code N after, killed after, lost. Icons are freedesktop names: emblem-default, dialog-error, process-stop, dialog-warning, computer. Co-Authored-By: Claude Opus 5.5 --- sb_builder/fmt.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'sb_builder/fmt.py') 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"] -- cgit v1.2.3