forked from public/mirror-checker
commit
8c305397b9
@ -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 |
@ -1,3 +0,0 @@ |
||||
"""Contains shared constants""" |
||||
|
||||
CSC_MIRROR = "http://mirror.csclub.uwaterloo.ca/" |
@ -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 |
@ -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 |
@ -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) |
Loading…
Reference in new issue