projects/cpan: trust CPAN's mirror status
This commit is contained in:
parent
9f345c7b0c
commit
612ec9d04b
|
@ -9,13 +9,14 @@ from shared import CSC_MIRROR
|
||||||
|
|
||||||
|
|
||||||
class CPAN(Project):
|
class CPAN(Project):
|
||||||
"""CPAN class"""
|
"""CPAN class"""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def check(data, project, current_time):
|
def check(data, project, current_time):
|
||||||
res_json = requests.get("http://mirrors.cpan.org/cpan-json.txt").json()
|
res_json = requests.get("http://mirrors.cpan.org/cpan-json.txt").json()
|
||||||
for mirror in res_json:
|
for mirror in res_json:
|
||||||
if mirror["url"] == f"{CSC_MIRROR}CPAN/":
|
if mirror["url"] == f"{CSC_MIRROR}CPAN/" and mirror["last_status"] == "ok":
|
||||||
data[project]["out_of_sync_since"] = int(mirror["age"])
|
# This is an improvised method: report we're good if CPAN think we are good
|
||||||
return current_time - data[project]["out_of_sync_since"] <= data[project]["out_of_sync_interval"]
|
# Change this to a more precise method if you find a better way to do it
|
||||||
return False
|
return True
|
||||||
|
return False
|
||||||
|
|
Loading…
Reference in New Issue