2021-09-04 12:03:18 -04:00
|
|
|
"""
|
|
|
|
Contains FreeBSD class
|
|
|
|
"""
|
|
|
|
|
2021-10-03 15:44:08 -04:00
|
|
|
from project import Project
|
2022-03-26 21:04:17 -04:00
|
|
|
from shared import CSC_MIRROR
|
|
|
|
import requests
|
2021-10-03 15:35:17 -04:00
|
|
|
|
2021-10-03 15:44:08 -04:00
|
|
|
class FreeBSD(Project):
|
2022-03-26 21:04:17 -04:00
|
|
|
"""FreeBSD class"""
|
|
|
|
|
|
|
|
# FreeBSD's time file has two segments, so we need a special function
|
|
|
|
# Example TIMESTAMP file: 1648308600 2022-03-26T15:30:00 UTC
|
|
|
|
def check(data, project, current_time):
|
|
|
|
"""Check if project packages are up-to-date"""
|
|
|
|
csc_url = CSC_MIRROR + data[project]["csc"] + data[project]["file"]
|
|
|
|
upstream_url = data[project]["upstream"] + data[project]["file"]
|
|
|
|
|
|
|
|
req = requests.get(csc_url)
|
|
|
|
req.raise_for_status()
|
|
|
|
CSC = req.text
|
|
|
|
|
|
|
|
req = requests.get(upstream_url)
|
|
|
|
req.raise_for_status()
|
|
|
|
upstream = req.text
|
|
|
|
|
|
|
|
if upstream == CSC:
|
|
|
|
return True
|
|
|
|
try:
|
|
|
|
return get_timestamp_for_freebsd(upstream) - get_timestamp_for_freebsd(CSC) < data[project]["out_of_sync_interval"]
|
|
|
|
except ValueError:
|
|
|
|
print("failed to parse apache")
|
|
|
|
return False
|
|
|
|
|
|
|
|
def get_timestamp_for_freebsd(s: str) -> int:
|
|
|
|
real_time = s.split(" ")[0]
|
|
|
|
return int(real_time)
|