Merge pull request 'fix CTAN && trust CPAN's report' (#8) from y266shen/mirror-checker:feature-retry into master
Reviewed-on: #8
This commit is contained in:
commit
e1ef917af0
|
@ -15,7 +15,8 @@ class CPAN(Project):
|
|||
def check(data, project, current_time):
|
||||
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"]
|
||||
if mirror["url"] == f"{CSC_MIRROR}CPAN/" and mirror["last_status"] == "ok":
|
||||
# This is an improvised method: report we're good if CPAN think we are good
|
||||
# Change this to a more precise method if you find a better way to do it
|
||||
return True
|
||||
return False
|
||||
|
|
|
@ -7,7 +7,7 @@ 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, timedelta
|
||||
import re
|
||||
import pandas as pd
|
||||
|
||||
|
@ -20,7 +20,8 @@ class ctan(Project):
|
|||
|
||||
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))
|
||||
data[project]["out_of_sync_since"] = datetime.now() - duration.total_seconds()
|
||||
data[project]["out_of_sync_since"] = datetime.now() - duration
|
||||
|
||||
return duration <= pd.to_timedelta(data[project]["out_of_sync_interval"], unit='s')
|
||||
|
|
Loading…
Reference in New Issue