From 2afcf22ad1841a0fd653a4fca72ab37eee4b4b02 Mon Sep 17 00:00:00 2001 From: Bruce Dawson Date: Mon, 25 Feb 2019 22:07:08 +0000 Subject: [PATCH] Check for impossible date ranges If you specify the wrong year to the -b flag then you may end up with an inverted time range that is entirely in the future, and this causes odd failures. Or at least that's what I've heard. This detects some of these error cases and halts. Also a one-line git cl format cleanup. Change-Id: Iede80faed00d4857443b3a1d853fa2ba69f47023 Reviewed-on: https://chromium-review.googlesource.com/c/1487744 Commit-Queue: Bruce Dawson Auto-Submit: Bruce Dawson Reviewed-by: Dirk Pranke --- my_activity.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/my_activity.py b/my_activity.py index 77b5f09c4..48f14055d 100755 --- a/my_activity.py +++ b/my_activity.py @@ -700,7 +700,7 @@ class MyActivity(object): if self.changes: self.print_heading('Changes') for change in self.changes: - self.print_change(change) + self.print_change(change) def print_access_errors(self): if self.access_errors: @@ -1039,6 +1039,12 @@ def main(): else: end = datetime.today() options.begin, options.end = begin, end + if begin >= end: + # The queries fail in peculiar ways when the begin date is in the future. + # Give a descriptive error message instead. + logging.error('Start date (%s) is the same or later than end date (%s)' % + (begin, end)) + return 1 if options.markdown: options.output_format_heading = '### {heading}\n'