mirror-checker/projects/ubuntu.py

25 lines
838 B
Python
Raw Normal View History

2021-10-03 18:26:43 -04:00
"""
Contains ubuntu class
2021-10-03 18:26:43 -04:00
"""
import os
2021-10-04 01:18:07 -04:00
from project import Project
2021-10-03 18:26:43 -04:00
from shared import CSC_MIRROR
import requests
import datefinder # another date finding library
2021-10-04 01:18:07 -04:00
from datetime import timedelta
from datetime import datetime
import re
import pandas as pd
2021-10-03 18:26:43 -04:00
2021-10-04 01:18:07 -04:00
class ubuntu(Project):
2021-10-03 18:26:43 -04:00
"""ubuntu class"""
@staticmethod
2021-10-04 01:18:07 -04:00
def check(data, project, current_time):
page = requests.get(data[project]["upstream"]).text
indexOfFile = page.find("last verified")
2021-10-03 18:26:43 -04:00
matches = list(datefinder.find_dates(page[indexOfFile:]))
2021-10-04 01:18:07 -04:00
date = matches[0] # date is of type datetime.datetime
return(pd.to_datetime(current_time, unit='s') - date.replace(tzinfo=None) <= pd.to_timedelta(data[project]["out_of_sync_interval"], unit='s'))
2021-10-03 18:26:43 -04:00
# https://launchpad.net/ubuntu/+mirror/mirror.csclub.uwaterloo.ca-archive