Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1313)

Unified Diff: appengine/findit/util_scripts/crash_queries/crash_printer/print_crash.py

Issue 2391823006: [Findit] Add iterator and crash_iterator for delta test (Closed)
Patch Set: Address comments. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: appengine/findit/util_scripts/crash_queries/crash_printer/print_crash.py
diff --git a/appengine/findit/util_scripts/crash_queries/crash_printer/print_crash.py b/appengine/findit/util_scripts/crash_queries/crash_printer/print_crash.py
new file mode 100644
index 0000000000000000000000000000000000000000..9c1a3b9abff5e37b41b471f8249986ae7ee69e91
--- /dev/null
+++ b/appengine/findit/util_scripts/crash_queries/crash_printer/print_crash.py
@@ -0,0 +1,51 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import argparse
+from datetime import date
+from datetime import datetime
+from datetime import timedelta
+import os
+
+from crash_queries.crash_printer import crash_printer
+
+_DATETIME_FORMAT = '%Y-%m-%d'
+_TODAY = date.today().strftime(_DATETIME_FORMAT)
+_A_YEAR_AGO = (date.today() - timedelta(days=365)).strftime(_DATETIME_FORMAT)
+
+
+if __name__ == '__main__':
+ argparser = argparse.ArgumentParser(
+ description='Print crashes.')
+
+ argparser.add_argument(
+ '--date',
+ '-d',
+ default='%s..%s' % (_A_YEAR_AGO, _TODAY),
stgao 2016/10/13 06:38:52 Can we separate the start and end dates into two p
Sharu Jiang 2016/10/13 20:31:16 Done.
+ help=('Should be in start_date..end_date format. '
+ 'E.g. 2015-09-31..2016-10-01.'
+ 'If the end date is missing, then it defaults to today. '
+ 'If the start date is missing, then it defaults to a year before '
+ 'the end date.'
+ 'Start date and end date to query data in [start_date, end_date)'))
+
+ argparser.add_argument(
+ '--client',
+ '-c',
+ default='fracas',
+ help=('Possible values are: fracas, cracas, clusterfuzz. Right now, only '
+ 'fracas is supported.'))
+
+ args = argparser.parse_args()
+
+ start_date, end_date = args.date.split('..')
+ if not end_date:
+ end_date = _TODAY
+ if not start_date:
+ start_date = (datetime.strptime(end_date, _DATETIME_FORMAT) -
+ timedelta(days=365)).strftime(_DATETIME_FORMAT)
+
+ crash_printer.CrashPrinter(args.client,
+ start_date=start_date, end_date=end_date,
+ app_id=os.getenv('APP_ID'))

Powered by Google App Engine
This is Rietveld 408576698