diff options
Diffstat (limited to 'scripts/newos4-maintain.py')
| -rw-r--r-- | scripts/newos4-maintain.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/scripts/newos4-maintain.py b/scripts/newos4-maintain.py index 8cc7c5a..01cc986 100644 --- a/scripts/newos4-maintain.py +++ b/scripts/newos4-maintain.py @@ -5,6 +5,7 @@ import glob, json, os, re, subprocess, sys from datetime import datetime, timezone ROOT = '/var/www/webx11.duckdns.org/spaces/newos4' +PAGE = '/var/www/webx11.duckdns.org/spaces/agando/downloads/changelog.html' WEB = 'https://webx11.duckdns.org/spaces/newos4' FIX = '--fix' in sys.argv DEEP = '--deep' in sys.argv @@ -134,6 +135,23 @@ def check_changelog(): r = run([sys.executable, script, '--check'], cwd=ROOT) if r.returncode == 0: add('PASS', 'changelog: ' + (r.stdout.strip() or 'current')) + # A version match is not freshness: if the cron dies, the page and the build stay in + # agreement forever while the page stops being regenerated. + import datetime as _dt + m = re.search(r'"generated"\s*:\s*"([^"]+)"', open(PAGE, encoding='utf-8').read()) + if not m: + add('FAIL', 'changelog: page has no generated timestamp') + return + try: + gen = _dt.datetime.strptime(m.group(1), '%Y-%m-%dT%H:%M:%SZ').replace(tzinfo=_dt.timezone.utc) + except ValueError: + add('FAIL', 'changelog: unreadable generated timestamp ' + m.group(1)) + return + age_h = (_dt.datetime.now(_dt.timezone.utc) - gen).total_seconds() / 3600.0 + if age_h > 48: + add('FAIL', 'changelog: generated %.0fh ago (>48h) - the daily job is not running' % age_h) + else: + add('PASS', 'changelog age %.1fh' % age_h) return stale = (r.stdout or r.stderr).strip().splitlines() stale = stale[-1][:150] if stale else 'stale' |