29 lines
796 B
Python
29 lines
796 B
Python
|
"""
|
||
|
Contains OpenBSD class
|
||
|
"""
|
||
|
|
||
|
import requests
|
||
|
from distro import Distro
|
||
|
from constants import CSC_MIRROR
|
||
|
|
||
|
class OpenBSD(Distro):
|
||
|
"""OpenBSD class"""
|
||
|
@staticmethod
|
||
|
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)
|
||
|
|
||
|
@staticmethod
|
||
|
def name():
|
||
|
"""Get name of OpenBSD"""
|
||
|
return "OpenBSD"
|
||
|
|
||
|
@staticmethod
|
||
|
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
|