| OLD | NEW |
| 1 #! /usr/bin/env python | 1 #! /usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright 2017 The Chromium Authors. All rights reserved. | 3 # Copyright 2017 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 import argparse | 7 import argparse |
| 8 import collections | 8 import collections |
| 9 import json | 9 import json |
| 10 import tempfile | 10 import tempfile |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 test_name, builder_name, build_number, | 299 test_name, builder_name, build_number, |
| 300 time.strftime('%Y_%m_%d_T%H_%M_%S')) | 300 time.strftime('%Y_%m_%d_T%H_%M_%S')) |
| 301 gsutil_path = os.path.join(BASE_DIR, 'third_party', 'catapult', | 301 gsutil_path = os.path.join(BASE_DIR, 'third_party', 'catapult', |
| 302 'third_party', 'gsutil', 'gsutil.py') | 302 'third_party', 'gsutil', 'gsutil.py') |
| 303 subprocess.check_call([ | 303 subprocess.check_call([ |
| 304 sys.executable, gsutil_path, '-h', "Content-Type:%s" % content_type, | 304 sys.executable, gsutil_path, '-h', "Content-Type:%s" % content_type, |
| 305 'cp', temp_file.name, 'gs://%s/%s' % (bucket, dest)]) | 305 'cp', temp_file.name, 'gs://%s/%s' % (bucket, dest)]) |
| 306 | 306 |
| 307 return '%s/%s/%s' % (server_url, bucket, dest) | 307 return '%s/%s/%s' % (server_url, bucket, dest) |
| 308 | 308 |
| 309 |
| 309 def main(): | 310 def main(): |
| 310 parser = argparse.ArgumentParser() | 311 parser = argparse.ArgumentParser() |
| 311 parser.add_argument('--json-file', help='Path of json file.') | 312 parser.add_argument('--json-file', help='Path of json file.') |
| 312 parser.add_argument('--cs-base-url', help='Base url for code search.', | 313 parser.add_argument('--cs-base-url', help='Base url for code search.', |
| 313 default='http://cs.chromium.org') | 314 default='http://cs.chromium.org') |
| 314 parser.add_argument('--bucket', help='Google storage bucket.', required=True) | 315 parser.add_argument('--bucket', help='Google storage bucket.', required=True) |
| 315 parser.add_argument('--builder-name', help='Builder name.') | 316 parser.add_argument('--builder-name', help='Builder name.') |
| 316 parser.add_argument('--build-number', help='Build number.') | 317 parser.add_argument('--build-number', help='Build number.') |
| 317 parser.add_argument('--test-name', help='The name of the test.', | 318 parser.add_argument('--test-name', help='The name of the test.', |
| 318 required=True) | 319 required=True) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 340 ' --task-summary-json=XXX command.)') | 341 ' --task-summary-json=XXX command.)') |
| 341 parser.add_argument( | 342 parser.add_argument( |
| 342 'positional', nargs='*', | 343 'positional', nargs='*', |
| 343 help='output.json from shards.') | 344 help='output.json from shards.') |
| 344 | 345 |
| 345 args = parser.parse_args() | 346 args = parser.parse_args() |
| 346 | 347 |
| 347 if ((args.build_properties is None) == | 348 if ((args.build_properties is None) == |
| 348 (args.build_number is None or args.builder_name is None)): | 349 (args.build_number is None or args.builder_name is None)): |
| 349 raise parser.error('Exactly one of build_perperties or ' | 350 raise parser.error('Exactly one of build_perperties or ' |
| 350 '(build_number or builder_names) should be given.') | 351 '(build_number or builder_name) should be given.') |
| 351 | 352 |
| 352 if (args.build_number is None) != (args.builder_name is None): | 353 if (args.build_number is None) != (args.builder_name is None): |
| 353 raise parser.error('args.build_number and args.builder_name ' | 354 raise parser.error('args.build_number and args.builder_name ' |
| 354 'has to be be given together' | 355 'has to be be given together' |
| 355 'or not given at all.') | 356 'or not given at all.') |
| 356 | 357 |
| 357 if (len(args.positional) == 0) == (args.json_file is None): | 358 if len(args.positional) == 0 and args.json_file is None: |
| 359 if args.output_json: |
| 360 with open(args.output_json, 'w') as f: |
| 361 json.dump({}, f) |
| 362 return |
| 363 elif len(args.positional) != 0 and args.json_file: |
| 358 raise parser.error('Exactly one of args.positional and ' | 364 raise parser.error('Exactly one of args.positional and ' |
| 359 'args.json_file should be given.') | 365 'args.json_file should be given.') |
| 360 | 366 |
| 361 if args.build_properties: | 367 if args.build_properties: |
| 362 build_properties = json.loads(args.build_properties) | 368 build_properties = json.loads(args.build_properties) |
| 363 if ((not 'buildnumber' in build_properties) or | 369 if ((not 'buildnumber' in build_properties) or |
| 364 (not 'buildername' in build_properties)): | 370 (not 'buildername' in build_properties)): |
| 365 raise parser.error('Build number/builder name not specified.') | 371 raise parser.error('Build number/builder name not specified.') |
| 366 build_number = build_properties['buildnumber'] | 372 build_number = build_properties['buildnumber'] |
| 367 builder_name = build_properties['buildername'] | 373 builder_name = build_properties['buildername'] |
| 368 elif args.build_number and args.builder_name: | 374 elif args.build_number and args.builder_name: |
| 369 build_number = args.build_number | 375 build_number = args.build_number |
| (...skipping 21 matching lines...) Expand all Loading... |
| 391 with open(json_file) as original_json_file: | 397 with open(json_file) as original_json_file: |
| 392 json_object = json.load(original_json_file) | 398 json_object = json.load(original_json_file) |
| 393 json_object['links'] = {'result_details': result_details_link} | 399 json_object['links'] = {'result_details': result_details_link} |
| 394 with open(args.output_json, 'w') as f: | 400 with open(args.output_json, 'w') as f: |
| 395 json.dump(json_object, f) | 401 json.dump(json_object, f) |
| 396 else: | 402 else: |
| 397 print result_details_link | 403 print result_details_link |
| 398 | 404 |
| 399 if __name__ == '__main__': | 405 if __name__ == '__main__': |
| 400 sys.exit(main()) | 406 sys.exit(main()) |
| OLD | NEW |