forked from public/mirror-checker
Refactor and use requirements file
This commit is contained in:
parent
6b0d3f4de9
commit
3428e81cec
|
@ -139,3 +139,4 @@ cython_debug/
|
||||||
|
|
||||||
# Idea
|
# Idea
|
||||||
.idea/
|
.idea/
|
||||||
|
*.txt~
|
||||||
|
|
17
cpan.py
17
cpan.py
|
@ -1,17 +0,0 @@
|
||||||
"""
|
|
||||||
Contains CPAN class
|
|
||||||
"""
|
|
||||||
|
|
||||||
import requests
|
|
||||||
from distro import Distro
|
|
||||||
from shared import CSC_MIRROR
|
|
||||||
|
|
||||||
class CPAN(Distro):
|
|
||||||
"""CPAN class"""
|
|
||||||
@staticmethod
|
|
||||||
def check(data, distro, current_time):
|
|
||||||
res_json = requests.get("http://mirrors.cpan.org/cpan-json.txt").json()
|
|
||||||
for mirror in res_json:
|
|
||||||
if mirror["url"] == f"{CSC_MIRROR}CPAN/":
|
|
||||||
return current_time - int(mirror["age"]) <= data[distro]["out_of_sync_interval"]
|
|
||||||
return False
|
|
358
data.json
358
data.json
|
@ -1,181 +1,181 @@
|
||||||
{
|
{
|
||||||
"AlmaLinux": {
|
"AlmaLinux": {
|
||||||
"out_of_sync_since": null,
|
"out_of_sync_since": null,
|
||||||
"out_of_sync_interval": 86400,
|
"out_of_sync_interval": 86400,
|
||||||
"csc": "",
|
"csc": "",
|
||||||
"upstream": "https://repo.almalinux.org/",
|
"upstream": "https://repo.almalinux.org/",
|
||||||
"file": "almalinux/TIME"
|
"file": "almalinux/TIME"
|
||||||
},
|
},
|
||||||
"Alpine": {
|
"Alpine": {
|
||||||
"out_of_sync_since": null,
|
"out_of_sync_since": null,
|
||||||
"out_of_sync_interval": 86400,
|
"out_of_sync_interval": 86400,
|
||||||
"csc": "",
|
"csc": "",
|
||||||
"upstream": "https://uk.alpinelinux.org/",
|
"upstream": "https://uk.alpinelinux.org/",
|
||||||
"file": "alpine/last-updated"
|
"file": "alpine/last-updated"
|
||||||
},
|
},
|
||||||
"Apache": {
|
"Apache": {
|
||||||
"out_of_sync_since": null,
|
"out_of_sync_since": null,
|
||||||
"out_of_sync_interval": 86400,
|
"out_of_sync_interval": 86400,
|
||||||
"csc": "apache/",
|
"csc": "apache/",
|
||||||
"upstream": "https://downloads.apache.org/",
|
"upstream": "https://downloads.apache.org/",
|
||||||
"file": "zzz/time.txt"
|
"file": "zzz/time.txt"
|
||||||
},
|
},
|
||||||
"Arch": {
|
"Arch": {
|
||||||
"out_of_sync_since": null,
|
"out_of_sync_since": null,
|
||||||
"out_of_sync_interval": 86400,
|
"out_of_sync_interval": 86400,
|
||||||
"csc": "archlinux/",
|
"csc": "archlinux/",
|
||||||
"upstream": "http://arch.mirror.constant.com/",
|
"upstream": "http://arch.mirror.constant.com/",
|
||||||
"file": "lastupdate"
|
"file": "lastupdate"
|
||||||
},
|
},
|
||||||
"CentOS": {
|
"CentOS": {
|
||||||
"out_of_sync_since": null,
|
"out_of_sync_since": null,
|
||||||
"out_of_sync_interval": 86400,
|
"out_of_sync_interval": 86400,
|
||||||
"csc": "",
|
"csc": "",
|
||||||
"upstream": "https://mirrors.edge.kernel.org/",
|
"upstream": "https://mirrors.edge.kernel.org/",
|
||||||
"file": "centos/TIME"
|
"file": "centos/TIME"
|
||||||
},
|
},
|
||||||
"Ceph": {
|
"Ceph": {
|
||||||
"out_of_sync_since": null,
|
"out_of_sync_since": null,
|
||||||
"out_of_sync_interval": 86400,
|
"out_of_sync_interval": 86400,
|
||||||
"csc": "ceph/",
|
"csc": "ceph/",
|
||||||
"upstream": "https://download.ceph.com/",
|
"upstream": "https://download.ceph.com/",
|
||||||
"file": "timestamp"
|
"file": "timestamp"
|
||||||
},
|
},
|
||||||
"CPAN": {
|
"CPAN": {
|
||||||
"out_of_sync_interval": 172800
|
"out_of_sync_interval": 172800
|
||||||
},
|
},
|
||||||
"Cygwin": {
|
"Cygwin": {
|
||||||
"out_of_sync_since": null,
|
"out_of_sync_since": null,
|
||||||
"out_of_sync_interval": 86400,
|
"out_of_sync_interval": 86400,
|
||||||
"csc": "cygwin/",
|
"csc": "cygwin/",
|
||||||
"upstream": "https://cygwin.mirror.globo.tech/",
|
"upstream": "https://cygwin.mirror.globo.tech/",
|
||||||
"file": "x86/sha512.sum"
|
"file": "x86/sha512.sum"
|
||||||
},
|
},
|
||||||
"Debian": {
|
"Debian": {
|
||||||
"out_of_sync_since": null,
|
"out_of_sync_since": null,
|
||||||
"out_of_sync_interval": 86400,
|
"out_of_sync_interval": 86400,
|
||||||
"csc": "",
|
"csc": "",
|
||||||
"upstream": "https://ftp-master.debian.org/",
|
"upstream": "https://ftp-master.debian.org/",
|
||||||
"file": "debian/project/trace/master"
|
"file": "debian/project/trace/master"
|
||||||
},
|
},
|
||||||
"DebianCD": {
|
"DebianCD": {
|
||||||
"out_of_sync_since": null,
|
"out_of_sync_since": null,
|
||||||
"out_of_sync_interval": 86400,
|
"out_of_sync_interval": 86400,
|
||||||
"csc": "",
|
"csc": "",
|
||||||
"upstream": "http://debian.mirror.estruxture.net/",
|
"upstream": "http://debian.mirror.estruxture.net/",
|
||||||
"file": "debian-cd/project/trace/cdimage.debian.org"
|
"file": "debian-cd/project/trace/cdimage.debian.org"
|
||||||
},
|
},
|
||||||
"DebianMultimedia": {
|
"DebianMultimedia": {
|
||||||
"out_of_sync_since": null,
|
"out_of_sync_since": null,
|
||||||
"out_of_sync_interval": 86400,
|
"out_of_sync_interval": 86400,
|
||||||
"csc": "debian-multimedia/",
|
"csc": "debian-multimedia/",
|
||||||
"upstream": "http://debian-mirrors.sdinet.de/deb-multimedia/",
|
"upstream": "http://debian-mirrors.sdinet.de/deb-multimedia/",
|
||||||
"file": "project/trace/deb-multimedia.org"
|
"file": "project/trace/deb-multimedia.org"
|
||||||
},
|
},
|
||||||
"DebianPorts": {
|
"DebianPorts": {
|
||||||
"out_of_sync_since": null,
|
"out_of_sync_since": null,
|
||||||
"out_of_sync_interval": 86400,
|
"out_of_sync_interval": 86400,
|
||||||
"csc": "",
|
"csc": "",
|
||||||
"upstream": "https://deb.debian.org/",
|
"upstream": "https://deb.debian.org/",
|
||||||
"file": "debian-ports/project/trace/porta.debian.org"
|
"file": "debian-ports/project/trace/porta.debian.org"
|
||||||
},
|
},
|
||||||
"DebianSecurity": {
|
"DebianSecurity": {
|
||||||
"out_of_sync_since": null,
|
"out_of_sync_since": null,
|
||||||
"out_of_sync_interval": 86400,
|
"out_of_sync_interval": 86400,
|
||||||
"csc": "",
|
"csc": "",
|
||||||
"upstream": "http://debian.mirror.iweb.ca/",
|
"upstream": "http://debian.mirror.iweb.ca/",
|
||||||
"file": "debian-security/project/trace/master"
|
"file": "debian-security/project/trace/master"
|
||||||
},
|
},
|
||||||
"Eclipse": {
|
"Eclipse": {
|
||||||
"out_of_sync_since": null,
|
"out_of_sync_since": null,
|
||||||
"out_of_sync_interval": 172800,
|
"out_of_sync_interval": 172800,
|
||||||
"csc": "eclipse/",
|
"csc": "eclipse/",
|
||||||
"upstream": "http://download.eclipse.org/",
|
"upstream": "http://download.eclipse.org/",
|
||||||
"file": "TIME"
|
"file": "TIME"
|
||||||
},
|
},
|
||||||
"Fedora": {
|
"Fedora": {
|
||||||
"out_of_sync_since": null,
|
"out_of_sync_since": null,
|
||||||
"out_of_sync_interval": 86400,
|
"out_of_sync_interval": 86400,
|
||||||
"csc": "fedora/",
|
"csc": "fedora/",
|
||||||
"upstream": "http://fedora.mirror.iweb.com/",
|
"upstream": "http://fedora.mirror.iweb.com/",
|
||||||
"file": "linux/development/rawhide/COMPOSE_ID"
|
"file": "linux/development/rawhide/COMPOSE_ID"
|
||||||
},
|
},
|
||||||
"FreeBSD": {
|
"FreeBSD": {
|
||||||
"out_of_sync_since": null,
|
"out_of_sync_since": null,
|
||||||
"out_of_sync_interval": 86400,
|
"out_of_sync_interval": 86400,
|
||||||
"csc": "",
|
"csc": "",
|
||||||
"upstream": "http://ftp4.freebsd.org/pub/",
|
"upstream": "http://ftp4.freebsd.org/pub/",
|
||||||
"file": "FreeBSD/TIMESTAMP"
|
"file": "FreeBSD/TIMESTAMP"
|
||||||
},
|
},
|
||||||
"GentooDistfiles": {
|
"GentooDistfiles": {
|
||||||
"out_of_sync_since": null,
|
"out_of_sync_since": null,
|
||||||
"out_of_sync_interval": 86400,
|
"out_of_sync_interval": 86400,
|
||||||
"csc": "gentoo-distfiles",
|
"csc": "gentoo-distfiles",
|
||||||
"upstream": "http://gentoo.mirrors.tera-byte.com/",
|
"upstream": "http://gentoo.mirrors.tera-byte.com/",
|
||||||
"file": "distfiles/timestamp.dev-local"
|
"file": "distfiles/timestamp.dev-local"
|
||||||
},
|
},
|
||||||
"GentooPortage": {
|
"GentooPortage": {
|
||||||
"out_of_sync_since": null,
|
"out_of_sync_since": null,
|
||||||
"out_of_sync_interval": 86400,
|
"out_of_sync_interval": 86400,
|
||||||
"csc": "rsync://rsync4.ca.gentoo.org/",
|
"csc": "rsync://rsync4.ca.gentoo.org/",
|
||||||
"upstream1": "rsync://rsync1.de.gentoo.org/",
|
"upstream1": "rsync://rsync1.de.gentoo.org/",
|
||||||
"upstream2": "rsync://rsync8.de.gentoo.org/",
|
"upstream2": "rsync://rsync8.de.gentoo.org/",
|
||||||
"file": "gentoo-portage/Manifest"
|
"file": "gentoo-portage/Manifest"
|
||||||
},
|
},
|
||||||
"GNOME": {
|
"GNOME": {
|
||||||
"out_of_sync_since": null,
|
"out_of_sync_since": null,
|
||||||
"out_of_sync_interval": 86400,
|
"out_of_sync_interval": 86400,
|
||||||
"csc": "gnome/",
|
"csc": "gnome/",
|
||||||
"upstream1": "https://download.gnome.org/",
|
"upstream1": "https://download.gnome.org/",
|
||||||
"upstream2": "https://mirrors.dotsrc.org/gnome/",
|
"upstream2": "https://mirrors.dotsrc.org/gnome/",
|
||||||
"upstream3": "https://muug.ca/mirror/gnome/",
|
"upstream3": "https://muug.ca/mirror/gnome/",
|
||||||
"file1": "core/",
|
"file1": "core/",
|
||||||
"file2": "cache.json"
|
"file2": "cache.json"
|
||||||
},
|
},
|
||||||
"GNU": {
|
"GNU": {
|
||||||
"out_of_sync_since": null,
|
"out_of_sync_since": null,
|
||||||
"out_of_sync_interval": 86400,
|
"out_of_sync_interval": 86400,
|
||||||
"csc": "",
|
"csc": "",
|
||||||
"upstream": "https://mirrors.kernel.org/",
|
"upstream": "https://mirrors.kernel.org/",
|
||||||
"file": "gnu/mirror-updated-timestamp.txt"
|
"file": "gnu/mirror-updated-timestamp.txt"
|
||||||
},
|
},
|
||||||
"Gutenberg": {
|
"Gutenberg": {
|
||||||
"out_of_sync_since": null,
|
"out_of_sync_since": null,
|
||||||
"out_of_sync_interval": 172800,
|
"out_of_sync_interval": 172800,
|
||||||
"csc": "gutenberg/",
|
"csc": "gutenberg/",
|
||||||
"upstream": "https://gutenberg.pglaf.org/",
|
"upstream": "https://gutenberg.pglaf.org/",
|
||||||
"file": "gutenberg.dcs"
|
"file": "gutenberg.dcs"
|
||||||
},
|
},
|
||||||
"IPFire": {
|
"IPFire": {
|
||||||
"out_of_sync_since": null,
|
"out_of_sync_since": null,
|
||||||
"out_of_sync_interval": 172800
|
"out_of_sync_interval": 172800
|
||||||
},
|
},
|
||||||
"KDE": {
|
"KDE": {
|
||||||
"out_of_sync_since": null,
|
"out_of_sync_since": null,
|
||||||
"out_of_sync_interval": 86400,
|
"out_of_sync_interval": 86400,
|
||||||
"csc": "kde/",
|
"csc": "kde/",
|
||||||
"upstream": "https://kde.c3sl.ufpr.br/",
|
"upstream": "https://kde.c3sl.ufpr.br/",
|
||||||
"file": "ls-lR"
|
"file": "ls-lR"
|
||||||
},
|
},
|
||||||
"KDEApplicationData": {
|
"KDEApplicationData": {
|
||||||
"out_of_sync_since": null,
|
"out_of_sync_since": null,
|
||||||
"out_of_sync_interval": 86400,
|
"out_of_sync_interval": 86400,
|
||||||
"csc": "kde-applicationdata/",
|
"csc": "kde-applicationdata/",
|
||||||
"upstream": "https://cdn.files.kde.org/",
|
"upstream": "https://cdn.files.kde.org/",
|
||||||
"file": "last-updated"
|
"file": "last-updated"
|
||||||
},
|
},
|
||||||
"Kernel": {
|
"Kernel": {
|
||||||
"out_of_sync_since": null,
|
"out_of_sync_since": null,
|
||||||
"out_of_sync_interval": 86400,
|
"out_of_sync_interval": 86400,
|
||||||
"csc": "kernel.org/",
|
"csc": "kernel.org/",
|
||||||
"upstream": "https://mirrors.edge.kernel.org/pub/",
|
"upstream": "https://mirrors.edge.kernel.org/pub/",
|
||||||
"file": "linux/kernel/next/sha256sums.asc"
|
"file": "linux/kernel/next/sha256sums.asc"
|
||||||
},
|
},
|
||||||
"OpenBSD": {
|
"OpenBSD": {
|
||||||
"out_of_sync_since": null,
|
"out_of_sync_since": null,
|
||||||
"out_of_sync_interval": 86400,
|
"out_of_sync_interval": 86400,
|
||||||
"csc": "",
|
"csc": "",
|
||||||
"upstream": "https://ftp.openbsd.org/pub/",
|
"upstream": "https://ftp.openbsd.org/pub/",
|
||||||
"file": "OpenBSD/timestamp"
|
"file": "OpenBSD/timestamp"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
18
distro.py
18
distro.py
|
@ -3,14 +3,18 @@ Contains abstract class for a distro
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from abc import ABC
|
from abc import ABC
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from shared import CSC_MIRROR
|
from shared import CSC_MIRROR
|
||||||
|
|
||||||
|
|
||||||
class Distro(ABC):
|
class Distro(ABC):
|
||||||
"""Abstract class for a distro"""
|
"""Abstract class for a distro"""
|
||||||
@staticmethod
|
|
||||||
def check(data, distro):
|
@staticmethod
|
||||||
"""Check if distro packages are up-to-date"""
|
def check(data, distro):
|
||||||
csc_url = CSC_MIRROR + data[distro]["csc"] + data[distro]["file"]
|
"""Check if distro packages are up-to-date"""
|
||||||
upstream_url = data[distro]["upstream"] + data[distro]["file"]
|
csc_url = CSC_MIRROR + data[distro]["csc"] + data[distro]["file"]
|
||||||
return requests.get(csc_url).text == requests.get(upstream_url).text
|
upstream_url = data[distro]["upstream"] + data[distro]["file"]
|
||||||
|
return requests.get(csc_url).text == requests.get(upstream_url).text
|
||||||
|
|
23
distros.json
23
distros.json
|
@ -1,5 +1,20 @@
|
||||||
[
|
[
|
||||||
["OpenBSD", "https://mirror.csclub.uwaterloo.ca/OpenBSD/", "https://ftp.openbsd.org/pub/OpenBSD/", "timestamp"],
|
[
|
||||||
["kernel", "http://mirror.csclub.uwaterloo.ca/kernel.org/linux/kernel/next/", "https://mirrors.edge.kernel.org/pub/linux/kernel/next/", "sha256sums.asc"],
|
"OpenBSD",
|
||||||
["debian", "http://mirror.csclub.uwaterloo.ca/debian/project/trace/", "https://ftp-master.debian.org/debian/project/trace/", "master"]
|
"https://mirror.csclub.uwaterloo.ca/OpenBSD/",
|
||||||
]
|
"https://ftp.openbsd.org/pub/OpenBSD/",
|
||||||
|
"timestamp"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"kernel",
|
||||||
|
"http://mirror.csclub.uwaterloo.ca/kernel.org/linux/kernel/next/",
|
||||||
|
"https://mirrors.edge.kernel.org/pub/linux/kernel/next/",
|
||||||
|
"sha256sums.asc"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"debian",
|
||||||
|
"http://mirror.csclub.uwaterloo.ca/debian/project/trace/",
|
||||||
|
"https://ftp-master.debian.org/debian/project/trace/",
|
||||||
|
"master"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
"""
|
|
||||||
Contains GentooPortage class
|
|
||||||
"""
|
|
||||||
|
|
||||||
import os
|
|
||||||
from distro import Distro
|
|
||||||
|
|
||||||
class GentooPortage(Distro):
|
|
||||||
"""GentooPortage class"""
|
|
||||||
@staticmethod
|
|
||||||
def check(data, distro):
|
|
||||||
rsync_command = "rsync -q {}{} {}"
|
|
||||||
os.system(rsync_command.format(data[distro]["csc"],
|
|
||||||
data[distro]["file"],
|
|
||||||
"csc_manifest"))
|
|
||||||
os.system(rsync_command.format(data[distro]["upstream1"],
|
|
||||||
data[distro]["file"],
|
|
||||||
"upstream_manifest1"))
|
|
||||||
os.system(rsync_command.format(data[distro]["upstream2"],
|
|
||||||
data[distro]["file"],
|
|
||||||
"upstream_manifest2"))
|
|
||||||
stream1 = os.popen("diff csc_manifest upstream_manifest1")
|
|
||||||
output1 = stream1.read()
|
|
||||||
stream2 = os.popen("diff csc_manifest upstream_manifest2")
|
|
||||||
output2 = stream2.read()
|
|
||||||
os.system("rm csc_manifest")
|
|
||||||
os.system("rm upstream_manifest1")
|
|
||||||
os.system("rm upstream_manifest2")
|
|
||||||
return 0 in [len(output1), len(output2)]
|
|
40
gnome.py
40
gnome.py
|
@ -1,40 +0,0 @@
|
||||||
"""
|
|
||||||
Contains GNOME class
|
|
||||||
"""
|
|
||||||
|
|
||||||
import re
|
|
||||||
import requests
|
|
||||||
from distro import Distro
|
|
||||||
from shared import CSC_MIRROR
|
|
||||||
|
|
||||||
class GNOME(Distro):
|
|
||||||
"""GNOME class"""
|
|
||||||
@staticmethod
|
|
||||||
def check(data, distro):
|
|
||||||
file = data[distro]["file1"]
|
|
||||||
csc_versions = requests.get(CSC_MIRROR + data[distro]["csc"] + file).text
|
|
||||||
upstream_versions = requests.get(data[distro]["upstream1"] + file).text
|
|
||||||
csc_latest = re.findall(r"\"\d+\.?\d*", csc_versions)[-1].lstrip('"')
|
|
||||||
upstream_latest = re.findall(r"\"\d+\.?\d*", upstream_versions)[-1].lstrip('"')
|
|
||||||
if csc_latest != upstream_latest:
|
|
||||||
return False
|
|
||||||
file += csc_latest + "/"
|
|
||||||
csc_versions = requests.get(CSC_MIRROR + data[distro]["csc"] + file).text
|
|
||||||
upstream_versions = requests.get(data[distro]["upstream1"] + file).text
|
|
||||||
csc_latest = re.findall(r"\"\d+\.?\w*\.?\w*", csc_versions)[-1].lstrip('"')
|
|
||||||
upstream_latest = re.findall(r"\"\d+\.?\w*\.?\w*", upstream_versions)[-1].lstrip('"')
|
|
||||||
if csc_latest != upstream_latest:
|
|
||||||
return False
|
|
||||||
file += csc_latest + "/"
|
|
||||||
csc_text = requests.get(CSC_MIRROR + data[distro]["csc"] + file
|
|
||||||
+ data[distro]["file2"]).text
|
|
||||||
try:
|
|
||||||
ret = csc_text == requests.get(data[distro]["upstream2"] + file
|
|
||||||
+ data[distro]["file2"]).text
|
|
||||||
except requests.exceptions.RequestException:
|
|
||||||
ret = False
|
|
||||||
try:
|
|
||||||
return ret or csc_text == requests.get(data[distro]["upstream3"] + file
|
|
||||||
+ data[distro]["file2"]).text
|
|
||||||
except requests.exceptions.RequestException:
|
|
||||||
return False
|
|
14
ipfire.py
14
ipfire.py
|
@ -1,14 +0,0 @@
|
||||||
"""
|
|
||||||
Contains IPFire class
|
|
||||||
"""
|
|
||||||
|
|
||||||
import requests
|
|
||||||
from distro import Distro
|
|
||||||
|
|
||||||
class IPFire(Distro):
|
|
||||||
"""IPFire class"""
|
|
||||||
@staticmethod
|
|
||||||
def check(data, distro):
|
|
||||||
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
|
|
182
main.py
182
main.py
|
@ -7,106 +7,108 @@ This mirror status checker determines whether CSC mirror is up-to-date with upst
|
||||||
import time
|
import time
|
||||||
import sys
|
import sys
|
||||||
import requests
|
import requests
|
||||||
from almalinux import AlmaLinux
|
from projects.almalinux import AlmaLinux
|
||||||
from alpine import Alpine
|
from projects.alpine import Alpine
|
||||||
from apache import Apache
|
from projects.apache import Apache
|
||||||
from arch import Arch
|
from projects.arch import Arch
|
||||||
from centos import CentOS
|
from projects.centos import CentOS
|
||||||
from ceph import Ceph
|
from projects.ceph import Ceph
|
||||||
from cpan import CPAN
|
from projects.cpan import CPAN
|
||||||
from cygwin import Cygwin
|
from projects.cygwin import Cygwin
|
||||||
from debian import Debian
|
from projects.debian import Debian
|
||||||
from debiancd import DebianCD
|
from projects.debiancd import DebianCD
|
||||||
from debianmultimedia import DebianMultimedia
|
from projects.debianmultimedia import DebianMultimedia
|
||||||
from debianports import DebianPorts
|
from projects.debianports import DebianPorts
|
||||||
from debiansecurity import DebianSecurity
|
from projects.debiansecurity import DebianSecurity
|
||||||
from eclipse import Eclipse
|
from projects.eclipse import Eclipse
|
||||||
from fedora import Fedora
|
from projects.fedora import Fedora
|
||||||
from freebsd import FreeBSD
|
from projects.freebsd import FreeBSD
|
||||||
from gentoodistfiles import GentooDistfiles
|
from projects.gentoodistfiles import GentooDistfiles
|
||||||
from gentooportage import GentooPortage
|
from projects.gentooportage import GentooPortage
|
||||||
from gnome import GNOME
|
from projects.gnome import GNOME
|
||||||
from gnu import GNU
|
from projects.gnu import GNU
|
||||||
from gutenberg import Gutenberg
|
from projects.gutenberg import Gutenberg
|
||||||
from ipfire import IPFire
|
from projects.ipfire import IPFire
|
||||||
from kde import KDE
|
from projects.kde import KDE
|
||||||
from kdeapplicationdata import KDEApplicationData
|
from projects.kdeapplicationdata import KDEApplicationData
|
||||||
from kernel import Kernel
|
from projects.kernel import Kernel
|
||||||
from openbsd import OpenBSD
|
from projects.openbsd import OpenBSD
|
||||||
from shared import CSC_MIRROR
|
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
|
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/
|
# http://theautomatic.net/2018/12/18/2-packages-for-extracting-dates-from-a-string-of-text-in-python/
|
||||||
import re # import regular expressions to remove stray numbers in string that might interfere with date finding
|
import re # import regular expressions to remove stray numbers in string that might interfere with date finding
|
||||||
import json # import json to read distro info stored in json file
|
import json # import json to read distro info stored in json file
|
||||||
|
|
||||||
|
import datefinder # another date finding library
|
||||||
|
|
||||||
import datefinder # another date finding library
|
|
||||||
|
|
||||||
def checker(directory_URL, file_name):
|
def checker(directory_URL, file_name):
|
||||||
page = requests.get(directory_URL).text
|
page = requests.get(directory_URL).text
|
||||||
indexOfFile = page.find(file_name)
|
indexOfFile = page.find(file_name)
|
||||||
# print(page)
|
# print(page)
|
||||||
|
|
||||||
# remove stray numbers (file size numbers in particular) that might interfere with date finding
|
# remove stray numbers (file size numbers in particular) that might interfere with date finding
|
||||||
segment_clean = re.sub(r'\s\d+\s', ' ', page[indexOfFile:]) # removes numbers for size
|
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
|
segment_clean = re.sub(r'\s\d+\w*\s', ' ', page[indexOfFile:]) # removes numbers + size unit. e.x. 50kb
|
||||||
# print(segment_clean)
|
# print(segment_clean)
|
||||||
|
|
||||||
# implementation using dateparser.search.search_dates
|
# implementation using dateparser.search.search_dates
|
||||||
# notes: some dates don't parse correctly with this tool
|
# notes: some dates don't parse correctly with this tool
|
||||||
# print(search_dates(page[indexOfFile:], languages=['en']))
|
# print(search_dates(page[indexOfFile:], languages=['en']))
|
||||||
# print(search_dates(page[indexOfFile:])[0])
|
# print(search_dates(page[indexOfFile:])[0])
|
||||||
|
|
||||||
# finds the dates in the segment after the file name
|
# finds the dates in the segment after the file name
|
||||||
# notes: a generator will be returned by the datefinder module. I'm typecasting it to a list. Please read the note of caution provided at the bottom.
|
# notes: a generator will be returned by the datefinder module. I'm typecasting it to a list. Please read the note of caution provided at the bottom.
|
||||||
matches = list(datefinder.find_dates(segment_clean))
|
matches = list(datefinder.find_dates(segment_clean))
|
||||||
# print(matches)
|
# print(matches)
|
||||||
|
|
||||||
|
if len(matches) > 0:
|
||||||
|
date = matches[0] # date is of type datetime.datetime
|
||||||
|
return (date.strftime("%m/%d/%Y, %H:%M:%S"))
|
||||||
|
else:
|
||||||
|
return ('No dates found')
|
||||||
|
|
||||||
if len(matches) > 0:
|
|
||||||
date = matches[0] # date is of type datetime.datetime
|
|
||||||
return(date.strftime("%m/%d/%Y, %H:%M:%S"))
|
|
||||||
else:
|
|
||||||
return('No dates found')
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
"""distros = json.load(open('distros.json',))
|
"""distros = json.load(open('distros.json',))
|
||||||
print(distros)
|
print(distros)
|
||||||
|
|
||||||
for distro in distros:
|
for distro in distros:
|
||||||
print(distro[0] + ":")
|
print(distro[0] + ":")
|
||||||
print("CSC mirror: " + checker(distro[1], distro[3]))
|
print("CSC mirror: " + checker(distro[1], distro[3]))
|
||||||
print("Official distro: " + checker(distro[2], distro[3]))"""
|
print("Official distro: " + checker(distro[2], distro[3]))"""
|
||||||
|
|
||||||
with open("data.json", "r", encoding = "utf-8") as file:
|
with open("data.json", "r", encoding="utf-8") as file:
|
||||||
data = json.load(file)
|
data = json.load(file)
|
||||||
if sys.stdin.isatty():
|
if sys.stdin.isatty():
|
||||||
distros = data
|
distros = data
|
||||||
else:
|
else:
|
||||||
distros = [distro.rstrip() for distro in sys.stdin.readlines()]
|
distros = [distro.rstrip() for distro in sys.stdin.readlines()]
|
||||||
current_time = int(time.time())
|
current_time = int(time.time())
|
||||||
for distro in distros:
|
for distro in distros:
|
||||||
try:
|
try:
|
||||||
if distro not in data:
|
if distro not in data:
|
||||||
print(f"Failure: {distro} does not exist")
|
print(f"Failure: {distro} does not exist")
|
||||||
continue
|
continue
|
||||||
distro_class = getattr(sys.modules[__name__], distro)
|
distro_class = getattr(sys.modules[__name__], distro)
|
||||||
if distro == "CPAN":
|
if distro == "CPAN":
|
||||||
checker_result = distro_class.check(data, distro, current_time)
|
checker_result = distro_class.check(data, distro, current_time)
|
||||||
if checker_result:
|
if checker_result:
|
||||||
print(f"Success: {distro} up-to-date")
|
print(f"Success: {distro} up-to-date")
|
||||||
else:
|
else:
|
||||||
print(f"Failure: {distro} out-of-sync")
|
print(f"Failure: {distro} out-of-sync")
|
||||||
continue
|
continue
|
||||||
checker_result = distro_class.check(data, distro)
|
checker_result = distro_class.check(data, distro)
|
||||||
if checker_result:
|
if checker_result:
|
||||||
data[distro]["out_of_sync_since"] = None
|
data[distro]["out_of_sync_since"] = None
|
||||||
elif data[distro]["out_of_sync_since"] is None:
|
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
|
||||||
elif current_time - data[distro]["out_of_sync_since"] \
|
elif current_time - data[distro]["out_of_sync_since"] \
|
||||||
> data[distro]["out_of_sync_interval"]:
|
> data[distro]["out_of_sync_interval"]:
|
||||||
print(f"Failure: {distro} out-of-sync")
|
print(f"Failure: {distro} out-of-sync")
|
||||||
continue
|
continue
|
||||||
print(f"Success: {distro} up-to-date")
|
print(f"Success: {distro} up-to-date")
|
||||||
except requests.exceptions.RequestException as err:
|
except requests.exceptions.RequestException as err:
|
||||||
print(f"Error: {distro}\n{err}")
|
print(f"Error: {distro}\n{err}")
|
||||||
with open("data.json", "w", encoding = "utf-8") as file:
|
with open("data.json", "w", encoding="utf-8") as file:
|
||||||
json.dump(data, file, indent = 4)
|
json.dump(data, file, indent=4)
|
||||||
|
|
|
@ -4,5 +4,6 @@ Contains AlmaLinux class
|
||||||
|
|
||||||
from distro import Distro
|
from distro import Distro
|
||||||
|
|
||||||
|
|
||||||
class AlmaLinux(Distro):
|
class AlmaLinux(Distro):
|
||||||
"""AlmaLinux class"""
|
"""AlmaLinux class"""
|
|
@ -4,5 +4,6 @@ Contains Alpine class
|
||||||
|
|
||||||
from distro import Distro
|
from distro import Distro
|
||||||
|
|
||||||
|
|
||||||
class Alpine(Distro):
|
class Alpine(Distro):
|
||||||
"""Alpine class"""
|
"""Alpine class"""
|
|
@ -4,5 +4,6 @@ Contains Apache class
|
||||||
|
|
||||||
from distro import Distro
|
from distro import Distro
|
||||||
|
|
||||||
|
|
||||||
class Apache(Distro):
|
class Apache(Distro):
|
||||||
"""Apache class"""
|
"""Apache class"""
|
|
@ -4,5 +4,6 @@ Contains Arch class
|
||||||
|
|
||||||
from distro import Distro
|
from distro import Distro
|
||||||
|
|
||||||
|
|
||||||
class Arch(Distro):
|
class Arch(Distro):
|
||||||
"""Arch class"""
|
"""Arch class"""
|
|
@ -4,5 +4,6 @@ Contains CentOS class
|
||||||
|
|
||||||
from distro import Distro
|
from distro import Distro
|
||||||
|
|
||||||
|
|
||||||
class CentOS(Distro):
|
class CentOS(Distro):
|
||||||
"""CentOS class"""
|
"""CentOS class"""
|
|
@ -4,5 +4,6 @@ Contains Ceph class
|
||||||
|
|
||||||
from distro import Distro
|
from distro import Distro
|
||||||
|
|
||||||
|
|
||||||
class Ceph(Distro):
|
class Ceph(Distro):
|
||||||
"""Ceph class"""
|
"""Ceph class"""
|
|
@ -0,0 +1,20 @@
|
||||||
|
"""
|
||||||
|
Contains CPAN class
|
||||||
|
"""
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
|
from distro import Distro
|
||||||
|
from shared import CSC_MIRROR
|
||||||
|
|
||||||
|
|
||||||
|
class CPAN(Distro):
|
||||||
|
"""CPAN class"""
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def check(data, distro, current_time):
|
||||||
|
res_json = requests.get("http://mirrors.cpan.org/cpan-json.txt").json()
|
||||||
|
for mirror in res_json:
|
||||||
|
if mirror["url"] == f"{CSC_MIRROR}CPAN/":
|
||||||
|
return current_time - int(mirror["age"]) <= data[distro]["out_of_sync_interval"]
|
||||||
|
return False
|
|
@ -4,5 +4,6 @@ Contains Cygwin class
|
||||||
|
|
||||||
from distro import Distro
|
from distro import Distro
|
||||||
|
|
||||||
|
|
||||||
class Cygwin(Distro):
|
class Cygwin(Distro):
|
||||||
"""Cygwin class"""
|
"""Cygwin class"""
|
|
@ -4,5 +4,6 @@ Contains Debian class
|
||||||
|
|
||||||
from distro import Distro
|
from distro import Distro
|
||||||
|
|
||||||
|
|
||||||
class Debian(Distro):
|
class Debian(Distro):
|
||||||
"""Debian class"""
|
"""Debian class"""
|
|
@ -4,5 +4,6 @@ Contains DebianCD class
|
||||||
|
|
||||||
from distro import Distro
|
from distro import Distro
|
||||||
|
|
||||||
|
|
||||||
class DebianCD(Distro):
|
class DebianCD(Distro):
|
||||||
"""DebianCD class"""
|
"""DebianCD class"""
|
|
@ -4,5 +4,6 @@ Contains DebianMultimedia class
|
||||||
|
|
||||||
from distro import Distro
|
from distro import Distro
|
||||||
|
|
||||||
|
|
||||||
class DebianMultimedia(Distro):
|
class DebianMultimedia(Distro):
|
||||||
"""DebianMultimedia class"""
|
"""DebianMultimedia class"""
|
|
@ -4,5 +4,6 @@ Contains DebianPorts class
|
||||||
|
|
||||||
from distro import Distro
|
from distro import Distro
|
||||||
|
|
||||||
|
|
||||||
class DebianPorts(Distro):
|
class DebianPorts(Distro):
|
||||||
"""DebianPorts class"""
|
"""DebianPorts class"""
|
|
@ -4,5 +4,6 @@ Contains DebianSecurity class
|
||||||
|
|
||||||
from distro import Distro
|
from distro import Distro
|
||||||
|
|
||||||
|
|
||||||
class DebianSecurity(Distro):
|
class DebianSecurity(Distro):
|
||||||
"""DebianSecurity class"""
|
"""DebianSecurity class"""
|
|
@ -4,5 +4,6 @@ Contains Eclipse class
|
||||||
|
|
||||||
from distro import Distro
|
from distro import Distro
|
||||||
|
|
||||||
|
|
||||||
class Eclipse(Distro):
|
class Eclipse(Distro):
|
||||||
"""Eclipse class"""
|
"""Eclipse class"""
|
|
@ -4,5 +4,6 @@ Contains Fedora class
|
||||||
|
|
||||||
from distro import Distro
|
from distro import Distro
|
||||||
|
|
||||||
|
|
||||||
class Fedora(Distro):
|
class Fedora(Distro):
|
||||||
"""Fedora class"""
|
"""Fedora class"""
|
|
@ -4,5 +4,6 @@ Contains FreeBSD class
|
||||||
|
|
||||||
from distro import Distro
|
from distro import Distro
|
||||||
|
|
||||||
|
|
||||||
class FreeBSD(Distro):
|
class FreeBSD(Distro):
|
||||||
"""FreeBSD class"""
|
"""FreeBSD class"""
|
|
@ -4,5 +4,6 @@ Contains GentooDistfiles class
|
||||||
|
|
||||||
from distro import Distro
|
from distro import Distro
|
||||||
|
|
||||||
|
|
||||||
class GentooDistfiles(Distro):
|
class GentooDistfiles(Distro):
|
||||||
"""GentooDistfiles class"""
|
"""GentooDistfiles class"""
|
|
@ -0,0 +1,32 @@
|
||||||
|
"""
|
||||||
|
Contains GentooPortage class
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
from distro import Distro
|
||||||
|
|
||||||
|
|
||||||
|
class GentooPortage(Distro):
|
||||||
|
"""GentooPortage class"""
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def check(data, distro):
|
||||||
|
rsync_command = "rsync -q {}{} {}"
|
||||||
|
os.system(rsync_command.format(data[distro]["csc"],
|
||||||
|
data[distro]["file"],
|
||||||
|
"csc_manifest"))
|
||||||
|
os.system(rsync_command.format(data[distro]["upstream1"],
|
||||||
|
data[distro]["file"],
|
||||||
|
"upstream_manifest1"))
|
||||||
|
os.system(rsync_command.format(data[distro]["upstream2"],
|
||||||
|
data[distro]["file"],
|
||||||
|
"upstream_manifest2"))
|
||||||
|
stream1 = os.popen("diff csc_manifest upstream_manifest1")
|
||||||
|
output1 = stream1.read()
|
||||||
|
stream2 = os.popen("diff csc_manifest upstream_manifest2")
|
||||||
|
output2 = stream2.read()
|
||||||
|
os.system("rm csc_manifest")
|
||||||
|
os.system("rm upstream_manifest1")
|
||||||
|
os.system("rm upstream_manifest2")
|
||||||
|
return 0 in [len(output1), len(output2)]
|
|
@ -0,0 +1,44 @@
|
||||||
|
"""
|
||||||
|
Contains GNOME class
|
||||||
|
"""
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
|
from distro import Distro
|
||||||
|
from shared import CSC_MIRROR
|
||||||
|
|
||||||
|
|
||||||
|
class GNOME(Distro):
|
||||||
|
"""GNOME class"""
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def check(data, distro):
|
||||||
|
file = data[distro]["file1"]
|
||||||
|
csc_versions = requests.get(CSC_MIRROR + data[distro]["csc"] + file).text
|
||||||
|
upstream_versions = requests.get(data[distro]["upstream1"] + file).text
|
||||||
|
csc_latest = re.findall(r"\"\d+\.?\d*", csc_versions)[-1].lstrip('"')
|
||||||
|
upstream_latest = re.findall(r"\"\d+\.?\d*", upstream_versions)[-1].lstrip('"')
|
||||||
|
if csc_latest != upstream_latest:
|
||||||
|
return False
|
||||||
|
file += csc_latest + "/"
|
||||||
|
csc_versions = requests.get(CSC_MIRROR + data[distro]["csc"] + file).text
|
||||||
|
upstream_versions = requests.get(data[distro]["upstream1"] + file).text
|
||||||
|
csc_latest = re.findall(r"\"\d+\.?\w*\.?\w*", csc_versions)[-1].lstrip('"')
|
||||||
|
upstream_latest = re.findall(r"\"\d+\.?\w*\.?\w*", upstream_versions)[-1].lstrip('"')
|
||||||
|
if csc_latest != upstream_latest:
|
||||||
|
return False
|
||||||
|
file += csc_latest + "/"
|
||||||
|
csc_text = requests.get(CSC_MIRROR + data[distro]["csc"] + file
|
||||||
|
+ data[distro]["file2"]).text
|
||||||
|
try:
|
||||||
|
ret = csc_text == requests.get(data[distro]["upstream2"] + file
|
||||||
|
+ data[distro]["file2"]).text
|
||||||
|
except requests.exceptions.RequestException:
|
||||||
|
ret = False
|
||||||
|
try:
|
||||||
|
return ret or csc_text == requests.get(data[distro]["upstream3"] + file
|
||||||
|
+ data[distro]["file2"]).text
|
||||||
|
except requests.exceptions.RequestException:
|
||||||
|
return False
|
|
@ -4,5 +4,6 @@ Contains GNU class
|
||||||
|
|
||||||
from distro import Distro
|
from distro import Distro
|
||||||
|
|
||||||
|
|
||||||
class GNU(Distro):
|
class GNU(Distro):
|
||||||
"""GNU class"""
|
"""GNU class"""
|
|
@ -4,5 +4,6 @@ Contains Gutenberg class
|
||||||
|
|
||||||
from distro import Distro
|
from distro import Distro
|
||||||
|
|
||||||
|
|
||||||
class Gutenberg(Distro):
|
class Gutenberg(Distro):
|
||||||
"""Gutenberg class"""
|
"""Gutenberg class"""
|
|
@ -0,0 +1,17 @@
|
||||||
|
"""
|
||||||
|
Contains IPFire class
|
||||||
|
"""
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
|
from distro import Distro
|
||||||
|
|
||||||
|
|
||||||
|
class IPFire(Distro):
|
||||||
|
"""IPFire class"""
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def check(data, distro):
|
||||||
|
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
|
|
@ -4,5 +4,6 @@ Contains KDE class
|
||||||
|
|
||||||
from distro import Distro
|
from distro import Distro
|
||||||
|
|
||||||
|
|
||||||
class KDE(Distro):
|
class KDE(Distro):
|
||||||
"""KDE class"""
|
"""KDE class"""
|
|
@ -4,5 +4,6 @@ Contains KDEApplicationData class
|
||||||
|
|
||||||
from distro import Distro
|
from distro import Distro
|
||||||
|
|
||||||
|
|
||||||
class KDEApplicationData(Distro):
|
class KDEApplicationData(Distro):
|
||||||
"""KDEApplicationData class"""
|
"""KDEApplicationData class"""
|
|
@ -4,5 +4,6 @@ Contains Kernel class
|
||||||
|
|
||||||
from distro import Distro
|
from distro import Distro
|
||||||
|
|
||||||
|
|
||||||
class Kernel(Distro):
|
class Kernel(Distro):
|
||||||
"""Kernel class"""
|
"""Kernel class"""
|
|
@ -4,5 +4,6 @@ Contains OpenBSD class
|
||||||
|
|
||||||
from distro import Distro
|
from distro import Distro
|
||||||
|
|
||||||
|
|
||||||
class OpenBSD(Distro):
|
class OpenBSD(Distro):
|
||||||
"""OpenBSD class"""
|
"""OpenBSD class"""
|
|
@ -0,0 +1,4 @@
|
||||||
|
requests~=2.26.0
|
||||||
|
datefinder~=0.7.1
|
||||||
|
|
||||||
|
dateparser~=1.0.0
|
Loading…
Reference in New Issue