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.

32 lines
1016 B

Contains Debian class
from datetime import datetime, timedelta
import requests
from distro import Distro
from shared import CSC_MIRROR
class Debian(Distro):
"""Debian class"""
def __get_dt(trace_file_url):
"""Get Debian datetime object from trace file"""
response_text = requests.get(trace_file_url).text
time_str = response_text.split('\n')[0]
return datetime.strptime(time_str, "%a %b %d %H:%M:%S UTC %Y")
def name():
"""Get name of Debian"""
return "Debian"
def check():
"""Check if Debian packages are up-to-date"""
official_dt = Debian.__get_dt("")
csc_dt = Debian.__get_dt(f"{CSC_MIRROR}debian/project/trace/master")
# Keep the table cell at
# green and not yellow
return official_dt < csc_dt + timedelta(hours = 7)