1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
#!/usr/bin/python3
import argparse
import json
import re
import subprocess
import sys
import time
def get_projects():
o = subprocess.run(
["icktool", "show", "/projects"], check=True, capture_output=True
)
projects = json.loads(o.stdout)
return [
p["project"]
for p in projects["projects"]
if not p["project"].startswith("dummy")
]
def get_latest_build_log(project):
o = subprocess.run(
["icktool", "show-latest-log", project], check=True, capture_output=True
)
return o.stdout.decode()
pat = re.compile(r"^Build starts at (?P<timestamp>\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d)")
def log_timestamp(log):
m = pat.match(log)
if m is None:
return None
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)
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)
|