diff options
| author | Danilo M. <danix@danix.xyz> | 2026-10-20 19:21:24 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-10-20 19:21:24 +0200 |
| commit | 32201a3d505b6b78da7ba15c2bb77093d52ec735 (patch) | |
| tree | 46a82794db61cc101c77d856790ad0a290121c6f /sb_builder/fmt.py | |
| parent | 81604635b5a15ce36d14c04931ace058552ee2f3 (diff) | |
| download | sb-builder-32201a3d505b6b78da7ba15c2bb77093d52ec735.tar.gz sb-builder-32201a3d505b6b78da7ba15c2bb77093d52ec735.zip | |
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 <noreply@anthropic.com>
Diffstat (limited to 'sb_builder/fmt.py')
| -rw-r--r-- | sb_builder/fmt.py | 10 |
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"] |
