From 4b3f85374e2bd1743262618e6b9a39f1bd37632c Mon Sep 17 00:00:00 2001 From: Laura Nguyen Date: Tue, 24 Aug 2021 17:34:39 -0400 Subject: [PATCH] Created GNU mirror status checker --- gnu.py | 21 +++++++++++++++++++++ main.py | 3 ++- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 gnu.py diff --git a/gnu.py b/gnu.py new file mode 100644 index 0000000..2d23ade --- /dev/null +++ b/gnu.py @@ -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 diff --git a/main.py b/main.py index ddd1335..9d71151 100644 --- a/main.py +++ b/main.py @@ -8,11 +8,12 @@ import requests from arch import Arch from debian import Debian from eclipse import Eclipse +from gnu import GNU from kernel import Kernel from openbsd import OpenBSD if __name__ == "__main__": - for distro in [Arch, Debian, Eclipse, Kernel, OpenBSD]: + for distro in [Arch, Debian, Eclipse, GNU, Kernel, OpenBSD]: try: distro.print_output(distro.check()) except requests.exceptions.RequestException as err: