added ctan

This commit is contained in:
Tom 2021-10-10 20:55:22 -07:00
parent 565fd092d2
commit 7728d3eaa6
4 changed files with 37 additions and 4 deletions

View File

@ -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

View File

@ -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": ""
}
}

View File

@ -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")

26
projects/ctan.py Normal file
View File

@ -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')