diff --git a/check-release.py b/check-release.py index e3511538..4d27b31c 100755 --- a/check-release.py +++ b/check-release.py @@ -1,10 +1,9 @@ #!/usr/bin/python3 import argparse -import requests import sys -from datetime import date, datetime -from dateutil.relativedelta import relativedelta +from datetime import date, datetime, timedelta +import requests verbose = False @@ -40,9 +39,10 @@ def get_file_support() -> date: support_day = datetime.fromtimestamp(0) for line in lines: if "SUPPORT_END" in line: - key, value = line.split('=') - value = value.strip() - support_day = date.fromisoformat(value) + _, value = line.split('=') + value = value.strip() + if value: + support_day = date.fromisoformat(value) return support_day def support_date_in_future() -> bool: @@ -53,18 +53,19 @@ def support_date_in_future() -> bool: # Get the necessary values from the operating system. today = datetime.today().date() log("Current date on tested system =>", today) - tomorrow = today + relativedelta(years=1) - log(f"Minimal future EOL =>", tomorrow) + tomorrow = today + timedelta(days=365) + log("Minimal SUPPORT_END calculated from system time =>", tomorrow) support = get_file_support() - log(f"/etc/os-release SUPPORT_END =>", support) + log("Real /etc/os-release SUPPORT_END =>", support) # Test if the support end date is in the future. result = False if support >= tomorrow: - log("SUPPORT_END is in the future.") + log("Real SUPPORT_END is one year in the future.") log("Test passed.") result = True else: + log("Real SUPPORT_END is NOT one year in the future.") log("Test failed.") result = False return result @@ -76,4 +77,3 @@ if result: sys.exit(12) else: sys.exit(25) -