29 lines
796 B
Raw Normal View History

Contains OpenBSD class
import requests
from distro import Distro
from constants import CSC_MIRROR
class OpenBSD(Distro):
"""OpenBSD class"""
def __get_sec(timestamp_file_url):
"""Get OpenBSD seconds since the Epoch from timestamp file"""
sec_str = requests.get(timestamp_file_url).text
return int(sec_str)
def name():
"""Get name of OpenBSD"""
return "OpenBSD"
def check():
"""Check if OpenBSD packages are up-to-date"""
official_sec = OpenBSD.__get_sec("https://ftp.openbsd.org/pub/OpenBSD/timestamp")
csc_sec = OpenBSD.__get_sec(f"{CSC_MIRROR}OpenBSD/timestamp")
# Out-of-sync by 1 day maximum
return official_sec < csc_sec + 86400