Chromium Code Reviews| Index: build/android/pylib/results/presentation/test_results_presentation.py |
| diff --git a/build/android/pylib/results/presentation/test_results_presentation.py b/build/android/pylib/results/presentation/test_results_presentation.py |
| index 3324784a4040100e77574208024121954943a889..807f24dffdec45bd8d2c97f2cbc76452c03f9ef2 100755 |
| --- a/build/android/pylib/results/presentation/test_results_presentation.py |
| +++ b/build/android/pylib/results/presentation/test_results_presentation.py |
| @@ -308,12 +308,12 @@ def upload_to_google_bucket(html, test_name, builder_name, build_number, |
| def main(): |
| parser = argparse.ArgumentParser() |
| - parser.add_argument('--json-file', help='Path of json file.', required=True) |
| + parser.add_argument('--json-file', help='Path of json file.') |
| parser.add_argument('--cs-base-url', help='Base url for code search.', |
| default='http://cs.chromium.org') |
| parser.add_argument('--bucket', help='Google storage bucket.', required=True) |
| - parser.add_argument('--builder-name', help='Builder name.', required=True) |
| - parser.add_argument('--build-number', help='Build number.', required=True) |
| + parser.add_argument('--builder-name', help='Builder name.') |
| + parser.add_argument('--build-number', help='Build number.') |
| parser.add_argument('--test-name', help='The name of the test.', |
| required=True) |
| parser.add_argument('--server-url', help='The url of the server.', |
| @@ -324,15 +324,61 @@ def main(): |
| 'whether to download the file, or view in browser.'), |
| default='text/html', |
| choices=['text/html', 'application/octet-stream']) |
| + parser.add_argument( |
| + '-o', '--output-json', |
| + help='(Swarming Merge Script API)' |
| + ' Output JSON file to create.') |
| + parser.add_argument( |
| + '--build-properties', |
| + help='(Swarming Merge Script API) ' |
| + 'Build property JSON file provided by recipes.') |
| + parser.add_argument( |
| + '--summary-json', |
| + help='(Swarming Merge Script API)' |
| + ' Summary of shard state running on swarming.' |
| + ' (Output of the swarming.py collect' |
| + ' --task-summary-json=XXX command.)') |
| + parser.add_argument( |
| + 'positional', nargs='*', |
| + help='output.json from shards.') |
| + |
| args = parser.parse_args() |
| - if os.path.exists(args.json_file): |
| - result_html_string = result_details(args.json_file, args.cs_base_url, |
| + |
| + if args.build_properties: |
|
jbudorick
2017/04/17 20:40:04
As written, your argument logic makes a lot of unc
BigBossZhiling
2017/04/17 21:56:11
Done.
|
| + build_properties = json.loads(args.build_properties) |
| + build_number = build_properties['buildnumber'] |
| + builder_name = build_properties['buildname'] |
| + else: |
| + build_number = args.build_number |
| + builder_name = args.builder_name |
| + |
| + if args.output_json: |
|
jbudorick
2017/04/17 20:40:04
Given how you're using args.output_json/output_jso
BigBossZhiling
2017/04/17 21:56:11
Done.
|
| + output_json = args.output_json |
| + |
| + if args.positional: |
|
jbudorick
2017/04/17 20:40:04
Here, we're expecting either json_file or position
BigBossZhiling
2017/04/17 21:56:11
Done.
|
| + json_file = args.positional[0] |
| + else: |
| + json_file = args.json_file |
| + |
| + |
| + if os.path.exists(json_file): |
|
jbudorick
2017/04/17 20:40:04
If you're going to check this here and not just fa
BigBossZhiling
2017/04/17 21:56:11
Done.
|
| + result_html_string = result_details(json_file, args.cs_base_url, |
| args.bucket, args.server_url) |
| - print upload_to_google_bucket(result_html_string.encode('UTF-8'), |
| - args.test_name, args.builder_name, |
| - args.build_number, args.bucket, |
| - args.server_url, args.content_type) |
| + result_details_link = upload_to_google_bucket( |
| + result_html_string.encode('UTF-8'), |
| + args.test_name, builder_name, |
| + build_number, args.bucket, |
| + args.server_url, args.content_type) |
| + |
| + if args.output_json: |
| + with open(json_file) as original_json_file: |
| + json_object = json.loads(original_json_file.read()) |
| + json_object['links'] = {'result_details': result_details_link} |
| + with open(output_json, 'w') as f: |
| + f.write(str(json_object)) |
| + else: |
| + print result_details_link |
| else: |
| raise IOError('--json-file %s not found.' % args.json_file) |