diff options
author | Lars Wirzenius <liw@liw.fi> | 2022-08-10 18:24:36 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2022-08-10 18:24:36 +0300 |
commit | 6dc0b89dc006425151d3cbc2eebebbbdbf0bfe52 (patch) | |
tree | a34dcb2c3dcee7bea89954e7f00688ed2f18e86a /trigger-old | |
parent | 90b69cd609539cfc45957af8fdb6c1bfc963be99 (diff) | |
download | liw-ci-6dc0b89dc006425151d3cbc2eebebbbdbf0bfe52.tar.gz |
trigger-old: add --time to show latest build time
Sponsored-by: author
Diffstat (limited to 'trigger-old')
-rwxr-xr-x | trigger-old | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/trigger-old b/trigger-old index 5e872c3..46d04ce 100755 --- a/trigger-old +++ b/trigger-old @@ -1,8 +1,10 @@ #!/usr/bin/python3 +import argparse import json import re import subprocess +import sys import time @@ -35,12 +37,24 @@ def log_timestamp(log): return m["timestamp"] +p = argparse.ArgumentParser() +p.add_argument("--time", action="store_true") +args = p.parse_args() + + day = 24 * 60 * 60 cutoff = time.localtime(time.time() - day * 7) new_enough = time.strftime("%Y-%m-%d %H:%M:%S", cutoff) -for project in sorted(get_projects()): - log = get_latest_build_log(project) - ts = log_timestamp(log) - if ts is None or ts < new_enough: - print(project) +projects = [ + (project, log_timestamp(get_latest_build_log(project))) + for project in list(sorted(get_projects())) +] + +if args.time: + for (project, ts) in projects: + print(ts or "never", project) +else: + for (project, ts) in projects: + if ts is None or ts < new_enough: + print(project) |