Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2016 The Chromium Authors. All rights reserved. | 2 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """This script is intended to archive retry summary results from | 6 """This script is intended to archive retry summary results from |
| 7 try bot retries for layout tests along with layout test results. | 7 try bot retries of layout tests. |
| 8 | 8 |
| 9 The purpose if this is so that these retry results can be fetched | 9 By keeping these retry summary results in the same place as the |
| 10 from the same place that the first run results are fetched. | 10 layout test results from the first try (with patch), the retry |
| 11 results can be easily fetched from the same location as the results. | |
| 11 """ | 12 """ |
| 12 | 13 |
| 14 import argparse | |
| 13 import logging | 15 import logging |
| 14 import argparse | |
| 15 import os | 16 import os |
| 16 import re | 17 import re |
| 17 import socket | 18 import socket |
| 19 import shutil | |
| 18 import sys | 20 import sys |
| 19 | 21 |
| 22 from slave import robust_tempdir | |
| 20 from slave import slave_utils | 23 from slave import slave_utils |
| 21 | 24 |
| 22 | 25 |
| 23 def ArchiveRetrySummary(args): | 26 def ArchiveRetrySummary(args): |
| 24 args.builder_name = re.sub('[ .()]', '_', args.builder_name) | 27 args.builder_name = re.sub('[ .()]', '_', args.builder_name) |
| 25 print 'Builder name: %s' % args.builder_name | 28 print 'Builder name: %s' % args.builder_name |
| 26 print 'Build number: %s' % args.build_number | 29 print 'Build number: %s' % args.build_number |
| 27 print 'Host name: %s' % socket.gethostname() | 30 print 'Host name: %s' % socket.gethostname() |
| 28 | 31 |
| 29 gs_base = '/'.join([args.gs_bucket, args.builder_name, args.build_number]) | 32 gs_base = '/'.join([args.gs_bucket, args.builder_name, args.build_number]) |
| 30 slave_utils.GSUtilCopyFile(args.retry_summary_json, | 33 with robust_tempdir.RobustTempdir(prefix='retry-summary') as temp_dir: |
| 31 gs_base, | 34 temp_path = os.path.join(temp_dir, 'retry_summary.json') |
|
Paweł Hajdan Jr.
2016/10/24 12:07:18
I'm wondering whether this works.
Could you expli
qyearsley
2016/10/24 16:48:48
Oh, I see -- robust_tempdir.RobustTempdir() gives
| |
| 32 cache_control="public, max-age=31556926") | 35 shutil.copyfile(args.retry_summary_json, temp_path) |
| 33 slave_utils.GSUtilMoveFile(os.path.join(gs_base, args.retry_summary_json), | 36 slave_utils.GSUtilCopyFile(temp_path, gs_base, |
|
Paweł Hajdan Jr.
2016/10/24 12:07:18
Why do we copy to temporary directory for this?
I
qyearsley
2016/10/24 16:48:48
The reason for this is that slave_utils.GSUtilCopy
| |
| 34 os.path.join(gs_base, 'retry_summary.json')) | 37 cache_control='public, max-age=31556926') |
| 35 return 0 | 38 return 0 |
| 36 | 39 |
| 37 | 40 |
| 38 def _ParseArgs(): | 41 def _ParseArgs(): |
| 39 parser = argparse.ArgumentParser() | 42 parser = argparse.ArgumentParser() |
| 40 parser.add_argument('--retry-summary-json', type=str, required=True, | 43 parser.add_argument('--retry-summary-json', type=str, required=True, |
| 41 help='path to retry summary JSON file') | 44 help='path to retry summary JSON file') |
| 42 parser.add_argument('--builder-name', type=str, required=True) | 45 parser.add_argument('--builder-name', type=str, required=True) |
| 43 parser.add_argument('--build-number', type=str, required=True) | 46 parser.add_argument('--build-number', type=str, required=True) |
| 44 parser.add_argument('--gs-bucket', type=str, required=True) | 47 parser.add_argument('--gs-bucket', type=str, required=True) |
| 45 return parser.parse_args() | 48 return parser.parse_args() |
| 46 | 49 |
| 47 | 50 |
| 48 def main(): | 51 def main(): |
| 49 args = _ParseArgs() | 52 args = _ParseArgs() |
| 50 logging.basicConfig(level=logging.INFO, | 53 logging.basicConfig(level=logging.INFO, |
| 51 format='%(asctime)s %(filename)s:%(lineno)-3d' | 54 format='%(asctime)s %(filename)s:%(lineno)-3d' |
| 52 ' %(levelname)s %(message)s', | 55 ' %(levelname)s %(message)s', |
| 53 datefmt='%y%m%d %H:%M:%S') | 56 datefmt='%y%m%d %H:%M:%S') |
| 54 return ArchiveRetrySummary(args) | 57 return ArchiveRetrySummary(args) |
| 55 | 58 |
| 56 | 59 |
| 57 if '__main__' == __name__: | 60 if '__main__' == __name__: |
| 58 sys.exit(main()) | 61 sys.exit(main()) |
| OLD | NEW |