mirror-checker/projects/cpan.py

22 lines
524 B
Python
Raw Permalink Normal View History

2021-10-03 15:35:17 -04:00
"""
Contains CPAN class
"""
import requests
2021-10-03 15:44:08 -04:00
from project import Project
2021-10-03 15:35:17 -04:00
from shared import CSC_MIRROR
2021-10-03 15:44:08 -04:00
class CPAN(Project):
2021-10-03 15:35:17 -04:00
"""CPAN class"""
@staticmethod
2021-10-03 15:44:08 -04:00
def check(data, project, current_time):
2021-10-03 15:35:17 -04:00
res_json = requests.get("http://mirrors.cpan.org/cpan-json.txt").json()
for mirror in res_json:
if mirror["url"] == f"{CSC_MIRROR}CPAN/":
data[project]["out_of_sync_since"] = int(mirror["age"])
return current_time - data[project]["out_of_sync_since"] <= data[project]["out_of_sync_interval"]
2021-10-03 15:35:17 -04:00
return False