From 6b3d94141d4a37bfbee7df3c051ccf37b1bf30e9 Mon Sep 17 00:00:00 2001 From: Fredrik Eriksson Date: Fri, 31 May 2019 19:35:56 +0200 Subject: [PATCH] fixed -w flag --- cronwrapper/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cronwrapper/__init__.py b/cronwrapper/__init__.py index 999dcd9..44a5b82 100755 --- a/cronwrapper/__init__.py +++ b/cronwrapper/__init__.py @@ -40,7 +40,7 @@ def parse_args(): help='Warn to stderr (as in "send mail") at most once within this time interval (seconds)', type=int, metavar='warn_interval', - default=[86400]) + default=86400) parser.add_argument( '-L', '--no-lock', @@ -184,7 +184,7 @@ def main(): r.write("\nFalse\n") res = False - previous_runs = [] + previous_runs = {} for root, dirs, files in os.walk(os.path.join(args.cachedir[0], args.name[0])): previous_runs = { os.path.join(root, d): datetime.datetime.strptime(d, time_format) @@ -217,9 +217,9 @@ def main(): if previous_runs: # Not the first failure... oldest = min(previous_runs.values()) - if now-oldest > datetime.timedelta(seconds=args.warn_interval[0]): + if now-oldest > datetime.timedelta(seconds=args.warn_interval): # we have failed for a long time, send a report - print("Cronjob is still failing after {} seconds ({} failures)\n".format(args.warn_interval[0], len(previous_runs))) + print("Cronjob is still failing after {} seconds ({} failures)\n".format(args.warn_interval, len(previous_runs))) print_runs(previous_runs.keys()) else: # Within limits, save the output for a later instance