Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2013 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 """Module that combines JSON summaries and outputs the summaries in HTML.""" | 6 """Module that combines JSON summaries and outputs the summaries in HTML.""" |
| 7 | 7 |
| 8 import glob | 8 import glob |
| 9 import json | 9 import json |
| 10 import optparse | 10 import optparse |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 34 NOPATCH_MESA_TEMPLATE_VAR = 'nopatch_mesa' | 34 NOPATCH_MESA_TEMPLATE_VAR = 'nopatch_mesa' |
| 35 WITHPATCH_MESA_TEMPLATE_VAR = 'withpatch_mesa' | 35 WITHPATCH_MESA_TEMPLATE_VAR = 'withpatch_mesa' |
| 36 GS_FILES_LOCATION_NO_PATCH_TEMPLATE_VAR = 'gs_http_files_location_nopatch' | 36 GS_FILES_LOCATION_NO_PATCH_TEMPLATE_VAR = 'gs_http_files_location_nopatch' |
| 37 GS_FILES_LOCATION_WITH_PATCH_TEMPLATE_VAR = 'gs_http_files_location_withpatch' | 37 GS_FILES_LOCATION_WITH_PATCH_TEMPLATE_VAR = 'gs_http_files_location_withpatch' |
| 38 GS_FILES_LOCATION_DIFFS_TEMPLATE_VAR = 'gs_http_files_location_diffs' | 38 GS_FILES_LOCATION_DIFFS_TEMPLATE_VAR = 'gs_http_files_location_diffs' |
| 39 GS_FILES_LOCATION_WHITE_DIFFS_TEMPLATE_VAR = 'gs_http_files_location_whitediffs' | 39 GS_FILES_LOCATION_WHITE_DIFFS_TEMPLATE_VAR = 'gs_http_files_location_whitediffs' |
| 40 | 40 |
| 41 | 41 |
| 42 class FileInfo(object): | 42 class FileInfo(object): |
| 43 """Container class that holds all file data.""" | 43 """Container class that holds all file data.""" |
| 44 def __init__(self, file_name, skp_location, num_pixels_differing, | 44 def __init__(self, file_name, skp_location, num_pixels_differing, |
|
epoger
2014/02/03 21:17:13
Please document parameters (throughout this file)
| |
| 45 percent_pixels_differing, weighted_diff_measure, | 45 percent_pixels_differing, weighted_diff_measure, |
| 46 max_diff_per_channel): | 46 max_diff_per_channel, perceptual_diff): |
| 47 self.file_name = file_name | 47 self.file_name = file_name |
| 48 self.diff_file_name = _GetDiffFileName(self.file_name) | 48 self.diff_file_name = _GetDiffFileName(self.file_name) |
| 49 self.skp_location = skp_location | 49 self.skp_location = skp_location |
| 50 self.num_pixels_differing = num_pixels_differing | 50 self.num_pixels_differing = num_pixels_differing |
| 51 self.percent_pixels_differing = percent_pixels_differing | 51 self.percent_pixels_differing = percent_pixels_differing |
| 52 self.weighted_diff_measure = weighted_diff_measure | 52 self.weighted_diff_measure = weighted_diff_measure |
| 53 self.max_diff_per_channel = max_diff_per_channel | 53 self.max_diff_per_channel = max_diff_per_channel |
| 54 self.perceptual_diff = perceptual_diff | |
| 54 | 55 |
| 55 | 56 |
| 56 def _GetDiffFileName(file_name): | 57 def _GetDiffFileName(file_name): |
| 57 file_name_no_ext, ext = os.path.splitext(file_name) | 58 file_name_no_ext, ext = os.path.splitext(file_name) |
| 58 return '%s-vs-%s%s' % (file_name_no_ext, file_name_no_ext, ext) | 59 return '%s-vs-%s%s' % (file_name_no_ext, file_name_no_ext, ext) |
| 59 | 60 |
| 60 | 61 |
| 61 class SlaveInfo(object): | 62 class SlaveInfo(object): |
| 62 """Container class that holds all slave data.""" | 63 """Container class that holds all slave data.""" |
| 63 def __init__(self, slave_name, failed_files, skps_location, | 64 def __init__(self, slave_name, failed_files, skps_location, |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 84 slave_name = data.keys()[0] | 85 slave_name = data.keys()[0] |
| 85 slave_data = data[slave_name] | 86 slave_data = data[slave_name] |
| 86 file_info_list = [] | 87 file_info_list = [] |
| 87 for failed_file in slave_data[json_summary_constants.JSONKEY_FAILED_FILES]: | 88 for failed_file in slave_data[json_summary_constants.JSONKEY_FAILED_FILES]: |
| 88 failed_file_name = failed_file[json_summary_constants.JSONKEY_FILE_NAME] | 89 failed_file_name = failed_file[json_summary_constants.JSONKEY_FILE_NAME] |
| 89 skp_location = posixpath.join( | 90 skp_location = posixpath.join( |
| 90 STORAGE_HTTP_BASE, | 91 STORAGE_HTTP_BASE, |
| 91 failed_file[ | 92 failed_file[ |
| 92 json_summary_constants.JSONKEY_SKP_LOCATION].lstrip('gs://')) | 93 json_summary_constants.JSONKEY_SKP_LOCATION].lstrip('gs://')) |
| 93 num_pixels_differing = failed_file[ | 94 num_pixels_differing = failed_file[ |
| 94 json_summary_constants.JSONKEY_NUM_PIXELS_DIFFERING] | 95 json_summary_constants.JSONKEY_NUM_PIXELS_DIFFERING] |
| 95 percent_pixels_differing = failed_file[ | 96 percent_pixels_differing = failed_file[ |
| 96 json_summary_constants.JSONKEY_PERCENT_PIXELS_DIFFERING] | 97 json_summary_constants.JSONKEY_PERCENT_PIXELS_DIFFERING] |
| 97 weighted_diff_measure = failed_file[ | 98 weighted_diff_measure = failed_file[ |
| 98 json_summary_constants.JSONKEY_WEIGHTED_DIFF_MEASURE] | 99 json_summary_constants.JSONKEY_WEIGHTED_DIFF_MEASURE] |
| 99 max_diff_per_channel = failed_file[ | 100 max_diff_per_channel = failed_file[ |
| 100 json_summary_constants.JSONKEY_MAX_DIFF_PER_CHANNEL] | 101 json_summary_constants.JSONKEY_MAX_DIFF_PER_CHANNEL] |
| 102 perceptual_similarity = failed_file[ | |
| 103 json_summary_constants.JSONKEY_PERCEPTUAL_SIMILARITY] | |
| 104 # Convert the perceptual_similarity into the perceptual_diff. | |
| 105 perceptual_diff = 100 - (perceptual_similarity * 100) | |
| 101 | 106 |
| 102 file_info = FileInfo( | 107 file_info = FileInfo( |
| 103 file_name=failed_file_name, | 108 file_name=failed_file_name, |
| 104 skp_location=skp_location, | 109 skp_location=skp_location, |
| 105 num_pixels_differing=num_pixels_differing, | 110 num_pixels_differing=num_pixels_differing, |
| 106 percent_pixels_differing=percent_pixels_differing, | 111 percent_pixels_differing=percent_pixels_differing, |
| 107 weighted_diff_measure=weighted_diff_measure, | 112 weighted_diff_measure=weighted_diff_measure, |
| 108 max_diff_per_channel=max_diff_per_channel) | 113 max_diff_per_channel=max_diff_per_channel, |
| 114 perceptual_diff=perceptual_diff) | |
| 109 file_info_list.append(file_info) | 115 file_info_list.append(file_info) |
| 110 | 116 |
| 111 slave_info = SlaveInfo( | 117 slave_info = SlaveInfo( |
| 112 slave_name=slave_name, | 118 slave_name=slave_name, |
| 113 failed_files=file_info_list, | 119 failed_files=file_info_list, |
| 114 skps_location=slave_data[json_summary_constants.JSONKEY_SKPS_LOCATION], | 120 skps_location=slave_data[json_summary_constants.JSONKEY_SKPS_LOCATION], |
| 115 files_location_nopatch=slave_data[ | 121 files_location_nopatch=slave_data[ |
| 116 json_summary_constants.JSONKEY_FILES_LOCATION_NOPATCH], | 122 json_summary_constants.JSONKEY_FILES_LOCATION_NOPATCH], |
| 117 files_location_withpatch=slave_data[ | 123 files_location_withpatch=slave_data[ |
| 118 json_summary_constants.JSONKEY_FILES_LOCATION_WITHPATCH], | 124 json_summary_constants.JSONKEY_FILES_LOCATION_WITHPATCH], |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 210 'Must specify json_summaries_dir, output_html_dir, ' | 216 'Must specify json_summaries_dir, output_html_dir, ' |
| 211 'render_pictures_args, nopatch_mesa and withpatch_mesa') | 217 'render_pictures_args, nopatch_mesa and withpatch_mesa') |
| 212 | 218 |
| 213 OutputToHTML( | 219 OutputToHTML( |
| 214 slave_name_to_info=CombineJsonSummaries(options.json_summaries_dir), | 220 slave_name_to_info=CombineJsonSummaries(options.json_summaries_dir), |
| 215 output_html_dir=options.output_html_dir, | 221 output_html_dir=options.output_html_dir, |
| 216 absolute_url=options.absolute_url, | 222 absolute_url=options.absolute_url, |
| 217 render_pictures_args=options.render_pictures_args, | 223 render_pictures_args=options.render_pictures_args, |
| 218 nopatch_mesa=options.nopatch_mesa, | 224 nopatch_mesa=options.nopatch_mesa, |
| 219 withpatch_mesa=options.withpatch_mesa) | 225 withpatch_mesa=options.withpatch_mesa) |
| OLD | NEW |