fixed merge conflicts

This commit is contained in:
Tom 2021-08-24 16:20:12 -07:00
commit 8c305397b9
10 changed files with 83 additions and 17 deletions

View File

@ -5,7 +5,7 @@ Contains Arch class
from datetime import datetime, timedelta
import requests
from distro import Distro
from constants import CSC_MIRROR
from shared import CSC_MIRROR
class Arch(Distro):
"""Arch class"""

21
ceph.py Normal file
View File

@ -0,0 +1,21 @@
"""
Contains Ceph class
"""
from distro import Distro
from shared import CSC_MIRROR, get_sec
class Ceph(Distro):
"""Ceph class"""
@staticmethod
def name():
"""Get name of Ceph"""
return "Ceph"
@staticmethod
def check():
"""Check if Ceph packages are up-to-date"""
official_sec = get_sec("https://download.ceph.com/timestamp")
csc_sec = get_sec(f"{CSC_MIRROR}ceph/timestamp")
# Out-of-sync by 1 day maximum
return official_sec < csc_sec + 86400

View File

@ -1,3 +0,0 @@
"""Contains shared constants"""
CSC_MIRROR = "http://mirror.csclub.uwaterloo.ca/"

View File

@ -5,7 +5,7 @@ Contains Debian class
from datetime import datetime, timedelta
import requests
from distro import Distro
from constants import CSC_MIRROR
from shared import CSC_MIRROR
class Debian(Distro):
"""Debian class"""

21
eclipse.py Normal file
View File

@ -0,0 +1,21 @@
"""
Contains Eclipse class
"""
from distro import Distro
from shared import CSC_MIRROR, get_sec
class Eclipse(Distro):
"""Eclipse class"""
@staticmethod
def name():
"""Get name of Eclipse"""
return "Eclipse"
@staticmethod
def check():
"""Check if Eclipse packages are up-to-date"""
official_sec = get_sec("http://download.eclipse.org/TIME")
csc_sec = get_sec(f"{CSC_MIRROR}eclipse/TIME")
# Out-of-sync by 2 days maximum
return official_sec < csc_sec + 172800

21
gnu.py Normal file
View File

@ -0,0 +1,21 @@
"""
Contains GNU class
"""
from distro import Distro
from shared import CSC_MIRROR, get_sec
class GNU(Distro):
"""GNU class"""
@staticmethod
def name():
"""Get name of GNU"""
return "GNU"
@staticmethod
def check():
"""Check if GNU packages are up-to-date"""
official_sec = get_sec("https://mirrors.kernel.org/gnu/mirror-updated-timestamp.txt")
csc_sec = get_sec(f"{CSC_MIRROR}gnu/mirror-updated-timestamp.txt")
# Out-of-sync by 1 day maximum
return official_sec < csc_sec + 86400

View File

@ -4,7 +4,7 @@ Contains Kernel class
import requests
from distro import Distro
from constants import CSC_MIRROR
from shared import CSC_MIRROR
class Kernel(Distro):
"""Kernel class"""

View File

@ -6,7 +6,10 @@ This mirror status checker determines whether CSC mirror is up-to-date with upst
import requests
from arch import Arch
from ceph import Ceph
from debian import Debian
from eclipse import Eclipse
from gnu import GNU
from kernel import Kernel
from openbsd import OpenBSD
from dateparser.search import search_dates # this library seems to be super slow but the other library: dateutil.parser gets some errors
@ -43,7 +46,7 @@ def checker(directory_URL, file_name):
return('No dates found')
if __name__ == "__main__":
"""for distro in [Arch, Debian, Kernel, OpenBSD]:
"""for distro in [Arch, Ceph, Debian, Eclipse, GNU, Kernel, OpenBSD]:
try:
distro.print_output(distro.check())
except requests.exceptions.RequestException as err:

View File

@ -2,18 +2,11 @@
Contains OpenBSD class
"""
import requests
from distro import Distro
from constants import CSC_MIRROR
from shared import CSC_MIRROR, get_sec
class OpenBSD(Distro):
"""OpenBSD class"""
@staticmethod
def __get_sec(timestamp_file_url):
"""Get OpenBSD seconds since the Epoch from timestamp file"""
sec_str = requests.get(timestamp_file_url).text
return int(sec_str)
@staticmethod
def name():
"""Get name of OpenBSD"""
@ -22,7 +15,7 @@ class OpenBSD(Distro):
@staticmethod
def check():
"""Check if OpenBSD packages are up-to-date"""
official_sec = OpenBSD.__get_sec("https://ftp.openbsd.org/pub/OpenBSD/timestamp")
csc_sec = OpenBSD.__get_sec(f"{CSC_MIRROR}OpenBSD/timestamp")
official_sec = get_sec("https://ftp.openbsd.org/pub/OpenBSD/timestamp")
csc_sec = get_sec(f"{CSC_MIRROR}OpenBSD/timestamp")
# Out-of-sync by 1 day maximum
return official_sec < csc_sec + 86400

10
shared.py Normal file
View File

@ -0,0 +1,10 @@
"""Contains shared constants and functions"""
import requests
CSC_MIRROR = "http://mirror.csclub.uwaterloo.ca/"
def get_sec(timestamp_file_url):
"""Get seconds since the Epoch from timestamp file"""
sec_str = requests.get(timestamp_file_url).text
return int(sec_str)