testing/merge_scripts/standard_isolated_script_merge.py
def StandardIsolatedScriptMerge(output_json, summary_json, jsons_to_merge):
  """Merge the contents of one or more results JSONs into a single JSON.

  Args:
    output_json: A path to a JSON file to which the merged results should be
      written.
    jsons_to_merge: A list of paths to JSON files that should be merged.
  """
  # summary.json is produced by swarming client itself. We are mostly interested
  # in the number of shards.
  try:
    with open(summary_json) as f:
      summary = json.load(f)
  except (IOError, ValueError):
    print((
        'summary.json is missing or can not be read',
        'Something is seriously wrong with swarming client or the bot.'),
        file=sys.stderr)
    return 1

  missing_shards = []
  shard_results_list = []
  for index, result in enumerate(summary['shards']):
    output_path = None
    if result:
      output_path = find_shard_output_path(index, result.get('task_id'),
                                           jsons_to_merge)
    if not output_path:
      missing_shards.append(index)
      continue

    with open(output_path) as f:
      try:
        json_contents = json.load(f)
      except ValueError:
        raise ValueError('Failed to parse JSON from %s' % j)
      shard_results_list.append(json_contents)

  merged_results = results_merger.merge_test_results(shard_results_list)
  if missing_shards:
    merged_results['missing_shards'] = missing_shards
    if 'global_tags' not in merged_results:
      merged_results['global_tags'] = []
    merged_results['global_tags'].append('UNRELIABLE_RESULTS')

  with open(output_json, 'w') as f:
    json.dump(merged_results, f)

  return 0
Merge the contents of one or more results JSONs into a single JSON.

  Args:
    output_json: A path to a JSON file to which the merged results should be
      written.
    jsons_to_merge: A list of paths to JSON files that should be merged.
  
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 .
def StandardIsolatedScriptMerge(output_json, summary_json, jsons_to_merge):
  try:
    with open(summary_json) as f:
      summary = json.load(f)
  except (IOError, ValueError):
    print((
        'summary.json is missing or can not be read',
        'Something is seriously wrong with swarming client or the bot.'),
        file=sys.stderr)
    return 1
  missing_shards = []
  shard_results_list = []
  for index, result in enumerate(summary['shards']):
    output_path = None
    if result:
      output_path = find_shard_output_path(index, result.get('task_id'),
                                           jsons_to_merge)
    if not output_path:
      missing_shards.append(index)
      continue
    with open(output_path) as f:
      try:
        json_contents = json.load(f)
      except ValueError:
        raise ValueError('Failed to parse JSON from %s' % j)
      shard_results_list.append(json_contents)
  merged_results = results_merger.merge_test_results(shard_results_list)
  if missing_shards:
    merged_results['missing_shards'] = missing_shards
    if 'global_tags' not in merged_results:
      merged_results['global_tags'] = []
    merged_results['global_tags'].append('UNRELIABLE_RESULTS')
  with open(output_json, 'w') as f:
    json.dump(merged_results, f)
  return 0
def StandardIsolatedScriptMerge ( output_json , summary_json , jsons_to_merge ) : try : with open ( summary_json ) as f : summary = json . load ( f ) except ( IOError , ValueError ) : print ( ( 'summary.json is missing or can not be read' , 'Something is seriously wrong with swarming client or the bot.' ) , file = sys . stderr ) return 1 missing_shards = [ ] shard_results_list = [ ] for index , result in enumerate ( summary [ 'shards' ] ) : output_path = None if result : output_path = find_shard_output_path ( index , result . get ( 'task_id' ) , jsons_to_merge ) if not output_path : missing_shards . append ( index ) continue with open ( output_path ) as f : try : json_contents = json . load ( f ) except ValueError : raise ValueError ( 'Failed to parse JSON from %s' % j ) shard_results_list . append ( json_contents ) merged_results = results_merger . merge_test_results ( shard_results_list ) if missing_shards : merged_results [ 'missing_shards' ] = missing_shards if 'global_tags' not in merged_results : merged_results [ 'global_tags' ] = [ ] merged_results [ 'global_tags' ] . append ( 'UNRELIABLE_RESULTS' ) with open ( output_json , 'w' ) as f : json . dump ( merged_results , f ) return 0
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:
    output_json: A path to a JSON file to which the merged results should be
      written.
    jsons_to_merge: A list of paths to JSON files that should be merged.
  """ # summary.json is produced by swarming client itself. We are mostly interested # in the number of shards.
output_json
A path to a JSON file to which the merged results should be
written.
A path to a JSON file to which the merged results should be written .
summary_json
jsons_to_merge
A list of paths to JSON files that should be merged.
A list of paths to JSON files that should be merged .