From 7728d3eaa60f46e257e99ff3654b04d5e822d77c Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 10 Oct 2021 20:55:22 -0700 Subject: [PATCH] added ctan --- README.md | 2 +- data.json | 11 +++++++++-- main.py | 2 +- projects/ctan.py | 26 ++++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 projects/ctan.py diff --git a/README.md b/README.md index db718f2..593dfbe 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,6 @@ to find repos of the mirrored projects to check, just search "projectName mirror not done: csclub -CTAN damnsmalllinux debian-backports debian-volatile @@ -50,6 +49,7 @@ centos ceph CPAN CRAN: https://cran.r-project.org/mirmon_report.html has a mirror tracker +CTAN: https://www.ctan.org/mirrors/mirmon has a mirror tracker Cygwin debian debian-cd diff --git a/data.json b/data.json index eb0d118..03c711f 100644 --- a/data.json +++ b/data.json @@ -21,7 +21,7 @@ "file": "zzz/time.txt" }, "Arch": { - "out_of_sync_since": 1633923341, + "out_of_sync_since": null, "out_of_sync_interval": 86400, "csc": "archlinux/", "upstream": "http://arch.mirror.constant.com/", @@ -193,7 +193,7 @@ "file": "" }, "vlc": { - "out_of_sync_since": null, + "out_of_sync_since": 1633924178, "out_of_sync_interval": 86400, "csc": "vlc/", "upstream": "http://download.videolan.org/pub/videolan/", @@ -296,5 +296,12 @@ "csc": "", "upstream": "https://cran.r-project.org/mirmon_report.html", "file": "" + }, + "ctan": { + "out_of_sync_since": null, + "out_of_sync_interval": 86400, + "csc": "", + "upstream": "https://www.ctan.org/mirrors/mirmon", + "file": "" } } \ No newline at end of file diff --git a/main.py b/main.py index e11dda4..d92bfa5 100644 --- a/main.py +++ b/main.py @@ -67,7 +67,7 @@ if __name__ == "__main__": print(f"Failure: {project} does not exist") continue project_class = getattr(sys.modules[__name__], project) - if project == "CPAN" or project == "ubuntu" or project == "ubuntu_releases" or project == "manjaro" or project == "mxlinux" or project == "mxlinux_iso" or project == "slackware" or project == "trisquel" or project == "cran": + if project == "CPAN" or project == "ubuntu" or project == "ubuntu_releases" or project == "manjaro" or project == "mxlinux" or project == "mxlinux_iso" or project == "slackware" or project == "trisquel" or project == "cran" or project == "ctan": checker_result = project_class.check(data, project, current_time) if checker_result: print(f"Success: {project} up-to-date") diff --git a/projects/ctan.py b/projects/ctan.py new file mode 100644 index 0000000..fbbdd13 --- /dev/null +++ b/projects/ctan.py @@ -0,0 +1,26 @@ +""" +Contains ctan class +""" + +import os +from project import Project +from shared import CSC_MIRROR +import requests +import datefinder # another date finding library +from datetime import timedelta +from datetime import datetime +import re +import pandas as pd + +class ctan(Project): + """cran class""" + @staticmethod + def check(data, project, current_time): + page = requests.get(data[project]["upstream"]).text + indexOfFile = page.find("mirror.csclub.uwaterloo.ca") + + m = re.search(r'(\d+ hour)|(\d+ hours)|(\d+(\.)?\d+ days)', page[indexOfFile:]) # solution from: https://stackoverflow.com/questions/21074100/how-to-convert-standard-timedelta-string-to-timedelta-object/21074460 + + duration = pd.to_timedelta(m.group(0)) + + return duration <= pd.to_timedelta(data[project]["out_of_sync_interval"], unit='s') \ No newline at end of file