From 031e245dee2e6aaccb7fe3028f3c8ea63c5fab56 Mon Sep 17 00:00:00 2001 From: Christian Rebischke Date: Fri, 3 Jan 2020 16:13:08 +0100 Subject: [PATCH] fix bug #71 --- .gitignore | 1 + controller.py | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index c11d4aa..57eb98e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ packer_cache/ *.box *.swp output-* +.vscode diff --git a/controller.py b/controller.py index 5126e34..5394ee7 100755 --- a/controller.py +++ b/controller.py @@ -12,8 +12,7 @@ import os.path API_URL = 'https://app.vagrantup.com/api/v1/box/archlinux/archlinux' -NOW = datetime.datetime.now() -THIS_MONTH = int(NOW.strftime("%m")) +NOW = datetime.date.today() LEN_RELEASES = 2 CWD = '/srv/arch-boxes/arch-boxes' ISO_PATH = '/srv/ftp/iso/latest/archlinux-' + NOW.strftime( @@ -58,8 +57,12 @@ def determine_missing_release(release_providers): def is_latest(release_version): - release_month = int(release_version.split(".")[1]) - return THIS_MONTH <= release_month + # we need to use .date() here, otherwise the compare is going to fail + release = datetime.datetime.strptime(release_version, "%Y.%m.%d").date() + # set the day to 1, because we only want to check for month and year + release = release.replace(day=1) + current_release = NOW.replace(day=1) + return current_release <= release def all_released(release_providers):