This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/comdev-people.git


The following commit(s) were added to refs/heads/main by this push:
     new 66dbfc0  Simplify DOW calculation
66dbfc0 is described below

commit 66dbfc0352220db09b4cf6e86720b0e4ccfdb6bd
Author: Sebb <s...@apache.org>
AuthorDate: Fri Jul 4 13:44:45 2025 +0100

    Simplify DOW calculation
    
    Also make it match expectations (0 = Sunday)
    Fix comparison so refresh still occurs on Monday
---
 tools/pgp.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/pgp.py b/tools/pgp.py
index 9c78c92..0e857af 100644
--- a/tools/pgp.py
+++ b/tools/pgp.py
@@ -19,7 +19,6 @@
 import os
 import sys
 import time
-import math
 import re
 import json
 import subprocess
@@ -31,7 +30,7 @@ def fremove(file):
         os.remove(file)
 
 BASE = '/var/www' # default base (overrideable for local testing)
-DOW = math.floor(time.time()/86400)%7 # generate rolling logs over 7 days
+DOW = time.strftime('%w') # generate rolling logs over 7 days (0 = Sunday)
 LOG = f"{BASE}/html/keys/pgp{DOW}.log"
 fremove(LOG)
 print(f"Log file {LOG}")
@@ -118,10 +117,11 @@ noRefresh = hasArg1 and sys.argv[1] == '--no-refresh' # 
skip refresh
 gpgLocal = hasArg1 and sys.argv[1] == '--gpg-local' # don't try to download 
keys (for testing)
 
 # refresh is expensive, only do it once a week
-if DOW == 4 and not noRefresh and not gpgLocal:
+if DOW == "1" and not noRefresh and not gpgLocal:
     print("Refreshing the pgp database...")
     log.write("Refreshing the pgp database\n")
     pgpfunc('--refresh') # does not seem to have useful status/stderr output
+    log.write(f"{time.asctime()} ...done\n")
     print("...done")
     
 # Drop any .asc files older than a couple of days

Reply via email to