]> git.ipfire.org Git - people/jschlag/pbs.git/commitdiff
mirror check: Catch any false responses
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 22 Oct 2017 22:30:28 +0000 (23:30 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 22 Oct 2017 22:30:28 +0000 (23:30 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/mirrors.py

index df6576a35526483586bbfb58293be2f8e49796eb..f3eb0419ede208dc571edf398eb6ee3441035011 100644 (file)
@@ -205,16 +205,22 @@ class Mirror(base.DataObject):
                        # in seconds since epoch UTC
                        try:
                                timestamp = int(response.body)
+
+                       # If we could not parse the timestamp, we probably got
+                       # an error page or something similar.
+                       # So that's an error then...
                        except ValueError:
-                               raise
+                               status = "ERROR"
 
-                       # Convert to datetime
-                       last_sync_at = datetime.datetime.utcfromtimestamp(timestamp)
+                       # Timestamp seems to be okay
+                       else:
+                               # Convert to datetime
+                               last_sync_at = datetime.datetime.utcfromtimestamp(timestamp)
 
-                       # Must have synced within 24 hours
-                       now = datetime.datetime.utcnow()
-                       if now - last_sync_at >= datetime.timedelta(hours=24):
-                               status = "OUTOFSYNC"
+                               # Must have synced within 24 hours
+                               now = datetime.datetime.utcnow()
+                               if now - last_sync_at >= datetime.timedelta(hours=24):
+                                       status = "OUTOFSYNC"
 
                except tornado.httpclient.HTTPError as e:
                        http_status = e.code