mirror-checker/projects/cran.py

27 lines
771 B
Python
Raw Normal View History

2021-10-10 23:40:33 -04:00
"""
Contains cran class
"""
import os
from project import Project
from shared import CSC_MIRROR
import requests
import datefinder # another date finding library
from datetime import timedelta
import re
import pandas as pd
class cran(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+ minutes?)|(\d+ hours?)|(\d+(\.)?\d+ days?)', page[indexOfFile:])
2021-10-10 23:40:33 -04:00
duration = pd.to_timedelta(m.group(0))
data[project]["out_of_sync_since"] = current_time - duration.total_seconds()
2021-10-10 23:40:33 -04:00
return duration <= pd.to_timedelta(data[project]["out_of_sync_interval"], unit='s')