diff options
| author | Scott Ostler <scottbot9000@gmail.com> | 2010-07-08 21:24:53 -0400 |
|---|---|---|
| committer | Scott Ostler <scottbot9000@gmail.com> | 2010-07-08 21:24:53 -0400 |
| commit | 0da0bad70e05fa56f774a6a2473934a17b57fc6e (patch) | |
| tree | 4154f3300c46a2550663e72d37551b865b4950fc | |
| parent | 974c8678c0b4cff7874144638d630a8ddc290859 (diff) | |
Fix logreport.py interval handling
| -rw-r--r-- | scripts/logreport.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/scripts/logreport.py b/scripts/logreport.py index 69b6e46..cdde7c7 100644 --- a/scripts/logreport.py +++ b/scripts/logreport.py @@ -326,6 +326,9 @@ def peek(iterable): raise ValueError('cannot peek on empty iterator') return first, itertools.chain([first], iterable) +def total_seconds(td): + return td.seconds + td.days * 24 * 3600 + def yield_log_windows(raw_iter, interval, parse_func, timekey): wrapped_iter = itertools.ifilter(None, itertools.imap(parse_func, itertools.count(1), raw_iter)) @@ -334,7 +337,8 @@ def yield_log_windows(raw_iter, interval, parse_func, timekey): start_time = first[timekey] def keyfunc(record): - return int((record[timekey] - start_time).seconds / interval.seconds) + diff = record[timekey] - start_time + return int(total_seconds(diff) / total_seconds(interval)) for i, g in itertools.groupby(wrapped_iter, keyfunc): yield start_time + (interval * i), list(g) |
