From 6f9a9a09521fa988d345b28198201ec6701c6702 Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 3 Oct 2021 15:26:43 -0700 Subject: [PATCH] added tdf, ubuntu, vlc --- README.md | 11 +++++++---- data.json | 53 +++++++++++++++++++++++++++++++++++++---------------- main.py | 11 +++++++---- tdf.py | 8 ++++++++ ubuntu.py | 29 +++++++++++++++++++++++++++++ vlc.py | 8 ++++++++ 6 files changed, 96 insertions(+), 24 deletions(-) create mode 100644 tdf.py create mode 100644 ubuntu.py create mode 100644 vlc.py diff --git a/README.md b/README.md index 9ed94d9..6958bb5 100644 --- a/README.md +++ b/README.md @@ -27,11 +27,14 @@ mxlinux: https://sourceforge.net/projects/mx-linux/ (scrap the last day?) linuxmint-packages pool: http://rsync-packages.linuxmint.com/pool/ scientific: https://scientificlinux.org/downloads/sl-mirrors/ (CSC not listed) slackware: https://mirrors.slackware.com/mirrorlist/ https://mirrors.slackware.com/slackware/ -tdf: https://download.documentfoundation.org/ -trisquel: https://trisquel.info/mirmon/index.html -ubuntu: https://launchpad.net/ubuntu/+mirror/mirror.csclub.uwaterloo.ca-archive ubuntu-ports: http://ports.ubuntu.com/ubuntu-ports/ ubuntu-ports-releases: https://cdimage.ubuntu.com/releases/ ubuntu-releases: https://releases.ubuntu.com/ +x.org: https://www.x.org/releases/ + +done: +tdf: https://download.documentfoundation.org/ +ubuntu: https://launchpad.net/ubuntu/+mirror/mirror.csclub.uwaterloo.ca-archive vlc: http://download.videolan.org/pub/videolan/ -x.org: https://www.x.org/releases/ \ No newline at end of file + +trisquel: https://trisquel.info/mirmon/index.html out of date website \ No newline at end of file diff --git a/data.json b/data.json index 41e1c9d..c9acd7e 100644 --- a/data.json +++ b/data.json @@ -1,6 +1,6 @@ { "AlmaLinux": { - "out_of_sync_since": null, + "out_of_sync_since": 1633294718, "out_of_sync_interval": 86400, "csc": "", "upstream": "https://repo.almalinux.org/", @@ -14,28 +14,28 @@ "file": "alpine/last-updated" }, "Apache": { - "out_of_sync_since": null, + "out_of_sync_since": 1633294718, "out_of_sync_interval": 86400, "csc": "apache/", "upstream": "https://downloads.apache.org/", "file": "zzz/time.txt" }, "Arch": { - "out_of_sync_since": null, + "out_of_sync_since": 1633294718, "out_of_sync_interval": 86400, "csc": "archlinux/", "upstream": "http://arch.mirror.constant.com/", "file": "lastupdate" }, "CentOS": { - "out_of_sync_since": null, + "out_of_sync_since": 1633294718, "out_of_sync_interval": 86400, "csc": "", "upstream": "https://mirrors.edge.kernel.org/", "file": "centos/TIME" }, "Ceph": { - "out_of_sync_since": null, + "out_of_sync_since": 1633294718, "out_of_sync_interval": 86400, "csc": "ceph/", "upstream": "https://download.ceph.com/", @@ -52,7 +52,7 @@ "file": "x86/sha512.sum" }, "Debian": { - "out_of_sync_since": null, + "out_of_sync_since": 1633294718, "out_of_sync_interval": 86400, "csc": "", "upstream": "https://ftp-master.debian.org/", @@ -73,7 +73,7 @@ "file": "project/trace/deb-multimedia.org" }, "DebianPorts": { - "out_of_sync_since": null, + "out_of_sync_since": 1633294718, "out_of_sync_interval": 86400, "csc": "", "upstream": "https://deb.debian.org/", @@ -87,28 +87,28 @@ "file": "debian-security/project/trace/master" }, "Eclipse": { - "out_of_sync_since": null, + "out_of_sync_since": 1633294718, "out_of_sync_interval": 172800, "csc": "eclipse/", "upstream": "http://download.eclipse.org/", "file": "TIME" }, "Fedora": { - "out_of_sync_since": null, + "out_of_sync_since": 1633298732, "out_of_sync_interval": 86400, "csc": "fedora/", "upstream": "http://fedora.mirror.iweb.com/", "file": "linux/development/rawhide/COMPOSE_ID" }, "FreeBSD": { - "out_of_sync_since": null, + "out_of_sync_since": 1633294718, "out_of_sync_interval": 86400, "csc": "", "upstream": "http://ftp4.freebsd.org/pub/", "file": "FreeBSD/TIMESTAMP" }, "GentooDistfiles": { - "out_of_sync_since": null, + "out_of_sync_since": 1633294718, "out_of_sync_interval": 86400, "csc": "gentoo-distfiles", "upstream": "http://gentoo.mirrors.tera-byte.com/", @@ -133,14 +133,14 @@ "file2": "cache.json" }, "GNU": { - "out_of_sync_since": null, + "out_of_sync_since": 1633294718, "out_of_sync_interval": 86400, "csc": "", "upstream": "https://mirrors.kernel.org/", "file": "gnu/mirror-updated-timestamp.txt" }, "Gutenberg": { - "out_of_sync_since": null, + "out_of_sync_since": 1633294718, "out_of_sync_interval": 172800, "csc": "gutenberg/", "upstream": "https://gutenberg.pglaf.org/", @@ -158,7 +158,7 @@ "file": "ls-lR" }, "KDEApplicationData": { - "out_of_sync_since": null, + "out_of_sync_since": 1633294718, "out_of_sync_interval": 86400, "csc": "kde-applicationdata/", "upstream": "https://cdn.files.kde.org/", @@ -172,10 +172,31 @@ "file": "linux/kernel/next/sha256sums.asc" }, "OpenBSD": { - "out_of_sync_since": null, + "out_of_sync_since": 1633294718, "out_of_sync_interval": 86400, "csc": "", "upstream": "https://ftp.openbsd.org/pub/", "file": "OpenBSD/timestamp" + }, + "tdf": { + "out_of_sync_since": 1633294718, + "out_of_sync_interval": 86400, + "csc": "", + "upstream": "https://download.documentfoundation.org/TIMESTAMP", + "file": "tdf/TIMESTAMP" + }, + "ubuntu": { + "out_of_sync_since": null, + "out_of_sync_interval": 86400, + "csc": "", + "upstream": "https://launchpad.net/ubuntu/+mirror/mirror.csclub.uwaterloo.ca-archive", + "file": "" + }, + "vlc": { + "out_of_sync_since": 1633298732, + "out_of_sync_interval": 86400, + "csc": "vlc/", + "upstream": "http://download.videolan.org/pub/videolan/", + "file": "trace" } -} +} \ No newline at end of file diff --git a/main.py b/main.py index 15ca98e..25ad605 100644 --- a/main.py +++ b/main.py @@ -33,6 +33,9 @@ from kde import KDE from kdeapplicationdata import KDEApplicationData from kernel import Kernel from openbsd import OpenBSD +from tdf import tdf +from ubuntu import ubuntu +from vlc import vlc from shared import CSC_MIRROR from dateparser.search import search_dates # this library seems to be super slow but the other library: dateutil.parser gets some errors # http://theautomatic.net/2018/12/18/2-packages-for-extracting-dates-from-a-string-of-text-in-python/ @@ -90,7 +93,7 @@ if __name__ == "__main__": print(f"Failure: {distro} does not exist") continue distro_class = getattr(sys.modules[__name__], distro) - if distro == "CPAN": + if distro == "CPAN" or distro == "ubuntu": checker_result = distro_class.check(data, distro, current_time) if checker_result: print(f"Success: {distro} up-to-date") @@ -99,11 +102,11 @@ if __name__ == "__main__": continue checker_result = distro_class.check(data, distro) if checker_result: - data[distro]["out_of_sync_since"] = None + data[distro]["out_of_sync_since"] = None # out of sync since is just the last time we checked and returned true elif data[distro]["out_of_sync_since"] is None: - data[distro]["out_of_sync_since"] = current_time + data[distro]["out_of_sync_since"] = current_time # starts counting out of date elif current_time - data[distro]["out_of_sync_since"] \ - > data[distro]["out_of_sync_interval"]: + > data[distro]["out_of_sync_interval"]: # last time checked out of date, now still out of date, raise alert when it reaches this threshold print(f"Failure: {distro} out-of-sync") continue print(f"Success: {distro} up-to-date") diff --git a/tdf.py b/tdf.py new file mode 100644 index 0000000..c3f7e50 --- /dev/null +++ b/tdf.py @@ -0,0 +1,8 @@ +""" +Contains tdf class +""" + +from distro import Distro + +class tdf(Distro): + """tdf class""" diff --git a/ubuntu.py b/ubuntu.py new file mode 100644 index 0000000..26baa9a --- /dev/null +++ b/ubuntu.py @@ -0,0 +1,29 @@ +""" +Contains Trisquel class +""" + +import os +from distro import Distro +from shared import CSC_MIRROR +import requests +import datefinder # another date finding library + +class ubuntu(Distro): + """ubuntu class""" + @staticmethod + def check(data, distro, current_time): + page = requests.get(data[distro]["upstream"]).text + indexOfFile = page.find("last verified on") + # segment_clean = re.sub(r'\s\d+\s', ' ', page[indexOfFile:]) # removes numbers for size + # segment_clean = re.sub(r'\s\d+\w*\s', ' ', page[indexOfFile:]) # removes numbers + size unit. e.x. 50kb + + matches = list(datefinder.find_dates(page[indexOfFile:])) + # print(matches) + + if len(matches) > 0: + date = matches[0] # date is of type datetime.datetime + return(current_time - date.strftime("%Y/%m/%d, %H:%M:%S")) + else: + return(False) + + # https://launchpad.net/ubuntu/+mirror/mirror.csclub.uwaterloo.ca-archive \ No newline at end of file diff --git a/vlc.py b/vlc.py new file mode 100644 index 0000000..407392b --- /dev/null +++ b/vlc.py @@ -0,0 +1,8 @@ +""" +Contains vlc class +""" + +from distro import Distro + +class vlc(Distro): + """vlc class""" \ No newline at end of file