summaryrefslogtreecommitdiff
path: root/osm_proposals
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2025-08-28 07:38:47 +0200
committerMartin Fischer <martin@push-f.com>2025-08-28 07:39:08 +0200
commitf6e5ec8c75b434b74d9e2ed2abdb36e92f7255a1 (patch)
treee20b1638fe8de0bc95d56f833ea4c89eaf114ae5 /osm_proposals
parent3c9cf51274996427e7130a096e73c68d40edec90 (diff)
fix: only log connection errors as errors if last success was a day agoHEADmaster
Diffstat (limited to 'osm_proposals')
-rwxr-xr-xosm_proposals/proposals.py26
1 files changed, 25 insertions, 1 deletions
diff --git a/osm_proposals/proposals.py b/osm_proposals/proposals.py
index 5431e96..fff8c51 100755
--- a/osm_proposals/proposals.py
+++ b/osm_proposals/proposals.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
"""Queries wiki.openstreetmap.org for proposals and writes a JSON list of them to the given file."""
import argparse
+import datetime
import html
import json
import sys
@@ -29,7 +30,30 @@ def run():
arg_parser.add_argument("out_file")
args = arg_parser.parse_args()
- proposals = find_proposals()
+ try:
+ proposals = find_proposals()
+ except requests.exceptions.ConnectionError:
+ # For some reason the OSM wiki gives connection errors on average one per day (with this running hourly).
+ # Some days none, some days several.
+
+ with open(args.out_file, 'r') as f:
+ last_updated = datetime.datetime.fromtimestamp(json.load(f)["last_updated"])
+
+ age = datetime.datetime.now() - last_updated
+
+ if age > datetime.timedelta(days=1):
+ logger.error(
+ f"connection error escalated because last successful update was {age} ago",
+ traceback=True,
+ data_age=age.total_seconds(),
+ )
+ else:
+ logger.info(
+ f"connection error deemed ok because last successful update was {age} ago",
+ traceback=True,
+ data_age=age.total_seconds(),
+ )
+ return
with open(args.out_file, 'w') as f:
json.dump({"last_updated": int(time.time()), "proposals": proposals}, f)