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.

45 lines
1.3 KiB

11 months ago
Contains Artix class
import re
from datetime import datetime
import requests
11 months ago
from project import Project
from shared import CSC_MIRROR
11 months ago
def _get_date(url):
req = requests.head(url)
return datetime.strptime(req.headers['Last-Modified'], '%a, %d %b %Y %H:%M:%S %Z')
11 months ago
class Artix(Project):
"""Artix class"""
def check(cls, data, project, current_time):
csc_url = CSC_MIRROR + data[project]['csc']
upstream_url = data[project]['upstream']
req = requests.get(upstream_url)
index = req.text
repos = re.findall(r'href="(\w+)/"', index);
outdated_since = None
for repo in repos:
# Good enough for now, we can change it if Artix gets more arch in the future
db_path = repo + '/os/x86_64/' + repo + '.db'
upstream_date = _get_date(data[project]['upstream'] + db_path)
csc_date = _get_date(CSC_MIRROR + data[project]['csc'] + db_path)
if csc_date < upstream_date:
if outdated_since is None or upstream_date < outdated_since:
outdated_since = upstream_date
if outdated_since is not None:
data[project]['out_of_sync_since'] = int(outdated_since.timestamp())
return ( - outdated_since).total_seconds() < data[project]['out_of_sync_interval']
return True