third_party/blink/tools/blinkpy/web_tests/merge_results.py
def mark_missing_shards(summary_json,
                        input_directories,
                        merged_output_json,
                        fs=None):
    """Merge the contents of one or more results JSONs into a single JSON.

    Args:
        summary_json: swarming summary containing shard info.
        input_directories: A list of dir paths to JSON files that should be merged.
        merged_output_json: A path to a JSON file to which the merged results should be
        written.
        fs: filesystem object - MockFileSystem or FileSystem.
    """
    # summary.json is produced by swarming client.
    if fs != None:
        filesystem = fs
    else:
        filesystem = FileSystem()

    try:
        with filesystem.open_binary_file_for_reading(summary_json) as f:
            summary = json.load(f)
    except (IOError, ValueError) as e:
        raise MergeFailure('summary_json is missing or can not be read',
                           summary_json, None)

    missing_shards = []
    _log.debug("Missing shard processing: %s", input_directories)
    for index, result in enumerate(summary['shards']):
        output_path = None
        if result:
            output_path = find_shard_output_path(index, result.get('task_id'),
                                                 input_directories)
            if not output_path:
                missing_shards.append(index)

    if missing_shards:
        # TODO(crbug.com/1111954) - process summary_json along with others
        # so the merged output json can be written once to disk.
        with filesystem.open_binary_file_for_reading(merged_output_json) as f:
            try:
                json_contents_merged = json.load(f)
            except ValueError:
                raise MergeFailure(
                    'Failed to parse JSON from merged output.json',
                    merged_output_json, None)
        json_contents_merged['missing_shards'] = missing_shards

        with filesystem.open_binary_file_for_writing(merged_output_json) as f:
            MergeFilesJSONP.dump_jsonp(f, b'', json_contents_merged, b'')
Merge the contents of one or more results JSONs into a single JSON.

    Args:
        summary_json: swarming summary containing shard info.
        input_directories: A list of dir paths to JSON files that should be merged.
        merged_output_json: A path to a JSON file to which the merged results should be
        written.
        fs: filesystem object - MockFileSystem or FileSystem.
    
Merge the contents of one or more results JSONs into a single JSON.
Args:
summary_json: swarming summary containing shard info.
input_directories: A list of dir paths to JSON files that should be merged.
merged_output_json: A path to a JSON file to which the merged results should be
written.
fs: filesystem object - MockFileSystem or FileSystem.
Merge the contents of one or more results JSONs into a single JSON . Args : summary_json : swarming summary containing shard info . input_directories : A list of dir paths to JSON files that should be merged . merged_output_json : A path to a JSON file to which the merged results should be written . fs : filesystem object - MockFileSystem or FileSystem .
def mark_missing_shards(summary_json,
                        input_directories,
                        merged_output_json,
                        fs=None):
    if fs != None:
        filesystem = fs
    else:
        filesystem = FileSystem()
    try:
        with filesystem.open_binary_file_for_reading(summary_json) as f:
            summary = json.load(f)
    except (IOError, ValueError) as e:
        raise MergeFailure('summary_json is missing or can not be read',
                           summary_json, None)
    missing_shards = []
    _log.debug("Missing shard processing: %s", input_directories)
    for index, result in enumerate(summary['shards']):
        output_path = None
        if result:
            output_path = find_shard_output_path(index, result.get('task_id'),
                                                 input_directories)
            if not output_path:
                missing_shards.append(index)
    if missing_shards:
        with filesystem.open_binary_file_for_reading(merged_output_json) as f:
            try:
                json_contents_merged = json.load(f)
            except ValueError:
                raise MergeFailure(
                    'Failed to parse JSON from merged output.json',
                    merged_output_json, None)
        json_contents_merged['missing_shards'] = missing_shards
        with filesystem.open_binary_file_for_writing(merged_output_json) as f:
            MergeFilesJSONP.dump_jsonp(f, b'', json_contents_merged, b'')
def mark_missing_shards ( summary_json , input_directories , merged_output_json , fs = None ) : if fs != None : filesystem = fs else : filesystem = FileSystem ( ) try : with filesystem . open_binary_file_for_reading ( summary_json ) as f : summary = json . load ( f ) except ( IOError , ValueError ) as e : raise MergeFailure ( 'summary_json is missing or can not be read' , summary_json , None ) missing_shards = [ ] _log . debug ( "Missing shard processing: %s" , input_directories ) for index , result in enumerate ( summary [ 'shards' ] ) : output_path = None if result : output_path = find_shard_output_path ( index , result . get ( 'task_id' ) , input_directories ) if not output_path : missing_shards . append ( index ) if missing_shards : with filesystem . open_binary_file_for_reading ( merged_output_json ) as f : try : json_contents_merged = json . load ( f ) except ValueError : raise MergeFailure ( 'Failed to parse JSON from merged output.json' , merged_output_json , None ) json_contents_merged [ 'missing_shards' ] = missing_shards with filesystem . open_binary_file_for_writing ( merged_output_json ) as f : MergeFilesJSONP . dump_jsonp ( f , b'' , json_contents_merged , b'' )
Merge the contents of one or more results JSONs into a single JSON.
Merge the contents of one or more results JSONs into a single JSON .
"""Merge the contents of one or more results JSONs into a single JSON.

    Args:
        summary_json: swarming summary containing shard info.
        input_directories: A list of dir paths to JSON files that should be merged.
        merged_output_json: A path to a JSON file to which the merged results should be
        written.
        fs: filesystem object - MockFileSystem or FileSystem.
    """ # summary.json is produced by swarming client. # TODO(crbug.com/1111954) - process summary_json along with others # so the merged output json can be written once to disk.
summary_json
input_directories
merged_output_json
fs