2021-10-10 23:55:22 -04:00
|
|
|
"""
|
|
|
|
Contains ctan class
|
|
|
|
"""
|
|
|
|
|
|
|
|
import os
|
|
|
|
from project import Project
|
|
|
|
from shared import CSC_MIRROR
|
|
|
|
import requests
|
|
|
|
import datefinder # another date finding library
|
2022-03-30 00:15:08 -04:00
|
|
|
from datetime import datetime, timedelta
|
2021-10-10 23:55:22 -04:00
|
|
|
import re
|
|
|
|
import pandas as pd
|
|
|
|
|
|
|
|
class ctan(Project):
|
2021-11-14 20:44:42 -05:00
|
|
|
"""ctan class"""
|
2021-10-10 23:55:22 -04:00
|
|
|
@staticmethod
|
|
|
|
def check(data, project, current_time):
|
|
|
|
page = requests.get(data[project]["upstream"]).text
|
|
|
|
indexOfFile = page.find("mirror.csclub.uwaterloo.ca")
|
|
|
|
|
2022-04-14 13:56:59 -04:00
|
|
|
m = re.search(r'(\d+ minutes?)|(\d+ hours?)|(\d+(\.)?\d+ days?)', page[indexOfFile:])
|
2021-10-10 23:55:22 -04:00
|
|
|
|
2022-03-30 00:15:08 -04:00
|
|
|
|
2021-10-10 23:55:22 -04:00
|
|
|
duration = pd.to_timedelta(m.group(0))
|
2022-03-30 00:15:08 -04:00
|
|
|
data[project]["out_of_sync_since"] = datetime.now() - duration
|
2021-10-10 23:55:22 -04:00
|
|
|
|
2021-11-14 20:44:42 -05:00
|
|
|
return duration <= pd.to_timedelta(data[project]["out_of_sync_interval"], unit='s')
|