Created CPAN mirror status checker

dev
Laura Nguyen 1 year ago
parent 0ef22b660a
commit 273200abdf
  1. 3
      data.json
  2. 16
      main.py

@ -41,6 +41,9 @@
"upstream": "https://download.ceph.com/",
"file": "timestamp"
},
"CPAN": {
"out_of_date_interval": 172800
},
"Cygwin": {
"out_of_date_since": null,
"out_of_date_interval": 86400,

@ -20,6 +20,8 @@ import json # import json to read distro info stored in json file
import datefinder # another date finding library
CSC_MIRROR = "http://mirror.csclub.uwaterloo.ca/"
def checker(directory_URL, file_name):
page = requests.get(directory_URL).text
indexOfFile = page.find(file_name)
@ -53,8 +55,7 @@ def ipfire_checker():
def general_checker(data_json, distro_name):
"""General distro checker"""
csc_url = "http://mirror.csclub.uwaterloo.ca/" + data_json[distro_name]["csc"] \
+ data_json[distro_name]["file"]
csc_url = CSC_MIRROR + data_json[distro_name]["csc"] + data_json[distro_name]["file"]
upstream_url = data_json[distro_name]["upstream"] + data_json[distro_name]["file"]
return requests.get(csc_url).text == requests.get(upstream_url).text
@ -78,6 +79,17 @@ if __name__ == "__main__":
current_time = int(time.time())
for distro in data:
try:
if distro == "CPAN":
res_json = requests.get("http://mirrors.cpan.org/cpan-json.txt").json()
for mirror in res_json:
if mirror["url"] == f"{CSC_MIRROR}CPAN/":
if current_time - int(mirror["age"]) \
> data[distro]["out_of_date_interval"]:
print(f"Failure: {distro} out-of-sync")
else:
print(f"Success: {distro} up-to-date")
break
continue
if distro == "IPFire":
checker_result = ipfire_checker()
else:

Loading…
Cancel
Save