forked from public/mirror-checker
Improvements
This commit is contained in:
parent
03106f609f
commit
a33c73a7e9
2
main.py
2
main.py
|
@ -34,7 +34,7 @@ if __name__ == "__main__":
|
|||
else:
|
||||
print(f"Failure: {project} out-of-sync")
|
||||
continue
|
||||
checker_result = project_class.check(data, project)
|
||||
checker_result = project_class.check(data, project, current_time)
|
||||
if checker_result:
|
||||
data[project]["out_of_sync_since"] = None
|
||||
elif data[project]["out_of_sync_since"] is None:
|
||||
|
|
|
@ -13,7 +13,7 @@ class Project(ABC):
|
|||
"""Abstract class for a mirrored project"""
|
||||
|
||||
@staticmethod
|
||||
def check(data, project):
|
||||
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"]
|
||||
|
|
|
@ -13,7 +13,7 @@ import re
|
|||
import pandas as pd
|
||||
|
||||
class ctan(Project):
|
||||
"""cran class"""
|
||||
"""ctan class"""
|
||||
@staticmethod
|
||||
def check(data, project, current_time):
|
||||
page = requests.get(data[project]["upstream"]).text
|
||||
|
|
|
@ -18,7 +18,7 @@ class GentooPortage(Project):
|
|||
"""GentooPortage class"""
|
||||
|
||||
@staticmethod
|
||||
def check(data, project):
|
||||
def check(data, project, current_time):
|
||||
"""rsync_command = "rsync -q {}{} {}"
|
||||
os.system(rsync_command.format(data[project]["csc"],
|
||||
data[project]["file"],
|
||||
|
|
|
@ -14,7 +14,7 @@ class GNOME(Project):
|
|||
"""GNOME class"""
|
||||
|
||||
@staticmethod
|
||||
def check(data, project):
|
||||
def check(data, project, current_time):
|
||||
file = data[project]["file1"]
|
||||
csc_versions = requests.get(CSC_MIRROR + data[project]["csc"] + file).text
|
||||
upstream_versions = requests.get(data[project]["upstream1"] + file).text
|
||||
|
|
|
@ -11,7 +11,7 @@ class IPFire(Project):
|
|||
"""IPFire class"""
|
||||
|
||||
@staticmethod
|
||||
def check(data, project):
|
||||
def check(data, project, current_time):
|
||||
ipfire_url = "https://mirrors.ipfire.org/mirrors/mirror.csclub.uwaterloo.ca"
|
||||
ipfire_text = requests.get(ipfire_url).text
|
||||
return ipfire_text.find("The mirror is up") != -1
|
||||
|
|
|
@ -5,13 +5,14 @@ from datetime import datetime
|
|||
from project import Project
|
||||
from shared import CSC_MIRROR
|
||||
|
||||
|
||||
class sage(Project):
|
||||
"""sagemath class"""
|
||||
|
||||
@staticmethod
|
||||
def get_latest_date(dates):
|
||||
dates = [list(datefinder.find_dates(date))[0] for date in dates]
|
||||
return(max(dates))
|
||||
return max(dates)
|
||||
|
||||
@classmethod
|
||||
def check(cls, data, project):
|
||||
|
@ -36,7 +37,6 @@ class sage(Project):
|
|||
# if we have more entries than their mirror, ours must be the new one
|
||||
# since distros only add new versions, and don't delete old versions
|
||||
return True
|
||||
if (cls.get_latest_date(CSC_dates) < max([cls.get_latest_date(MIT_dates),cls.get_latest_date(SFU_dates)])):
|
||||
if cls.get_latest_date(CSC_dates) < max([cls.get_latest_date(MIT_dates), cls.get_latest_date(SFU_dates)]):
|
||||
return False
|
||||
return True
|
||||
|
|
@ -5,11 +5,12 @@ from datetime import datetime
|
|||
from project import Project
|
||||
from shared import CSC_MIRROR
|
||||
|
||||
|
||||
class saltstack(Project):
|
||||
"""saltstack class"""
|
||||
|
||||
@staticmethod
|
||||
def check(data, project):
|
||||
def check(data, project, current_time):
|
||||
csc_url = CSC_MIRROR + data[project]["csc"] + data[project]["file"]
|
||||
upstream_url = data[project]["upstream"] + data[project]["file"]
|
||||
|
||||
|
|
Loading…
Reference in New Issue