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.

36 lines
894 B

Contains abstract class for a mirrored project
from abc import ABC
import re
import requests
from shared import CSC_MIRROR
class Project(ABC):
"""Abstract class for a mirrored project"""
2 years ago
def check(data, project, current_time):
"""Check if project packages are up-to-date"""
csc_url = CSC_MIRROR + data[project]["csc"] + data[project]["file"]
upstream_url = data[project]["upstream"] + data[project]["file"]
CSC = requests.get(csc_url).text
upstream = requests.get(upstream_url).text
if upstream == CSC:
return True
# Parse number differences
bad_re = '[a-zA-Z \-\n]+'
if, CSC):
# print(, CSC).group().strip())
CSC = re.sub(bad_re, '', CSC)
upstream = re.sub(bad_re, '', upstream)
return int(upstream) - int(CSC) < data[project]["out_of_sync_interval"]
except ValueError:
return False