summaryrefslogtreecommitdiff
path: root/trigger-old
blob: 5e872c39c06175dca46e44a8d2cc5b68423d3c85 (plain)
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
#!/usr/bin/python3

import json
import re
import subprocess
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"]


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)