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.
|
|
|
"""
|
|
|
|
Contains Arch class
|
|
|
|
"""
|
|
|
|
|
|
|
|
from datetime import datetime, timedelta
|
|
|
|
import requests
|
|
|
|
from distro import Distro
|
|
|
|
from shared import CSC_MIRROR
|
|
|
|
|
|
|
|
class Arch(Distro):
|
|
|
|
"""Arch class"""
|
|
|
|
@staticmethod
|
|
|
|
def name():
|
|
|
|
"""Get name of Arch"""
|
|
|
|
return "Arch"
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def check():
|
|
|
|
"""Check if Arch packages are up-to-date"""
|
|
|
|
arch_json = requests.get("https://archlinux.org/mirrors/status/json/").json()
|
|
|
|
last_check_str = arch_json["last_check"]
|
|
|
|
last_sync_str = [url for url in arch_json["urls"] if url["url"] == \
|
|
|
|
f"{CSC_MIRROR}archlinux/"][0]["last_sync"]
|
|
|
|
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 https://archlinux.org/mirrors/status/:
|
|
|
|
# Due to the timing of mirror checks, any value under one hour should be viewed as ideal
|
|
|
|
return last_check_dt < last_sync_dt + timedelta(hours = 1)
|