Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/cygwin-apps/calm.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Turney <jon.turney@dronecode.org.uk>2016-03-29 14:21:56 +0300
committerJon Turney <jon.turney@dronecode.org.uk>2016-03-29 18:08:22 +0300
commit44c6acc7bfd161dda54dd03ad72d00776f3b54e4 (patch)
treec794a4b17de4f8ed866036c007e5a40a564feb3e
parent83dc7d12d415f8c2c2d941acc5b145bb8cbb28b8 (diff)
Don't emit warnings about ignored upload files on every run
Periodically emit warnings about apparently forgotten upload files which are being ignored, but not on every run v2: Don't count dryruns
-rw-r--r--testdata/.gitignore1
-rw-r--r--uploads.py38
2 files changed, 35 insertions, 4 deletions
diff --git a/testdata/.gitignore b/testdata/.gitignore
index 22f46b8..2dada27 100644
--- a/testdata/.gitignore
+++ b/testdata/.gitignore
@@ -4,3 +4,4 @@ results
setup.ini
sha512.sum
\!ready
+\!reminder-timestamp
diff --git a/uploads.py b/uploads.py
index 050c494..031e5c2 100644
--- a/uploads.py
+++ b/uploads.py
@@ -30,9 +30,13 @@ import filecmp
import os
import logging
import re
+import time
import package
+# reminders will be issued daily
+REMINDER_INTERVAL = 60*60*24
+
#
#
@@ -60,6 +64,15 @@ def scan(m, all_packages, args):
logging.info('processing files with mtime older than %d' % (mtime))
remove.append(ready)
+ # the mtime of this file indicates when 'ignoring as there is no !ready'
+ # warnings were last emitted
+ reminder_file = os.path.join(basedir, '!reminder-timestamp')
+ if os.path.exists(reminder_file):
+ reminder_time = os.path.getmtime(reminder_file)
+ else:
+ reminder_time = 0
+ logging.debug("reminder-timestamp %d, interval %d, next reminder %d, current time %d" % (reminder_time, REMINDER_INTERVAL, reminder_time + REMINDER_INTERVAL, time.time()))
+
# scan package directories
for (dirpath, subdirs, files) in os.walk(os.path.join(basedir, 'release')):
relpath = os.path.relpath(dirpath, basedir)
@@ -83,10 +96,9 @@ def scan(m, all_packages, args):
# shortest-to-longest order, since os.walk() walks the tree
# top-down), and use the mtime of the first (longest) matching path.
while True:
- (path, time) = mtimes[-1]
+ (path, mtime) = mtimes[-1]
if relpath.startswith(path):
- logging.info("using mtime %d from subpath '%s' of '%s'" % (time, path, relpath))
- mtime = time
+ logging.info("using mtime %d from subpath '%s' of '%s'" % (mtime, path, relpath))
break
else:
mtimes.pop()
@@ -116,7 +128,16 @@ def scan(m, all_packages, args):
# only process files newer than !ready
if os.path.getmtime(fn) > mtime:
if mtime == 0:
- logging.warning("ignoring %s as there is no !ready" % fn)
+ lvl = logging.INFO
+
+ # if more than REMINDER_INTERVAL has elapsed since we warned
+ # about files being ignored, warn again
+ if time.time() > (reminder_time + REMINDER_INTERVAL):
+ lvl = logging.WARNING
+ if not args.dryrun:
+ touch(reminder_file)
+
+ logging.log(lvl, "ignoring %s as there is no !ready" % fn)
else:
logging.warning("ignoring %s as it is newer than !ready" % fn)
files.remove(f)
@@ -159,6 +180,15 @@ def scan(m, all_packages, args):
#
#
+def touch(fn, times=None):
+ with open(fn, 'a'):
+ os.utime(fn, times)
+
+
+#
+#
+#
+
def remove(args, remove):
for f in remove:
logging.info("rm %s", f)