Check whether our mirror packages are up to date.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
1.1 KiB

#!/usr/bin/env python3
This mirror status checker determines whether CSC mirror is up-to-date with upstream
from datetime import datetime, timedelta
import requests
SUCCESS = "Success: {} up-to-date"
FAILURE = "Failure: {} out-of-sync"
ERROR = "Error: {}\n{}"
if __name__ == "__main__":
# Arch
arch_json = requests.get("").json()
last_check_str = arch_json["last_check"]
last_sync_str = [url for url in arch_json["urls"] if url["url"] == \
last_check_dt = datetime.strptime(last_check_str, "%Y-%m-%dT%H:%M:%S.%fZ")
last_sync_dt = datetime.strptime(last_sync_str, "%Y-%m-%dT%H:%M:%SZ")
# According to
# Due to the timing of mirror checks, any value under one hour should be viewed as ideal
OUTPUT = SUCCESS if last_check_dt < last_sync_dt + timedelta(hours = 1) else FAILURE
except requests.exceptions.RequestException as err:
print(ERROR.format("Arch", err))