Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Side by Side Diff: gm/rebaseline_server/imagediffdb.py

Issue 183833019: rebaseline_server: better reporting for bad URL fetch (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 2
3 """ 3 """
4 Copyright 2013 Google Inc. 4 Copyright 2013 Google Inc.
5 5
6 Use of this source code is governed by a BSD-style license that can be 6 Use of this source code is governed by a BSD-style license that can be
7 found in the LICENSE file. 7 found in the LICENSE file.
8 8
9 Calulate differences between image pairs, and store them in a database. 9 Calulate differences between image pairs, and store them in a database.
10 """ 10 """
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 actual_images_subdir: the subdirectory actual images are stored in. 84 actual_images_subdir: the subdirectory actual images are stored in.
85 image_suffix: the suffix of images. 85 image_suffix: the suffix of images.
86 """ 86 """
87 expected_image_locator = _sanitize_locator(expected_image_locator) 87 expected_image_locator = _sanitize_locator(expected_image_locator)
88 actual_image_locator = _sanitize_locator(actual_image_locator) 88 actual_image_locator = _sanitize_locator(actual_image_locator)
89 89
90 # Download the expected/actual images, if we don't have them already. 90 # Download the expected/actual images, if we don't have them already.
91 # TODO(rmistry): Add a parameter that makes _download_and_open_image raise 91 # TODO(rmistry): Add a parameter that makes _download_and_open_image raise
92 # an exception if images are not found locally (instead of trying to 92 # an exception if images are not found locally (instead of trying to
93 # download them). 93 # download them).
94 expected_image = _download_and_open_image( 94 expected_image_file = os.path.join(
95 os.path.join(storage_root, expected_images_subdir, 95 storage_root, expected_images_subdir,
96 str(expected_image_locator) + image_suffix), 96 str(expected_image_locator) + image_suffix)
97 expected_image_url) 97 actual_image_file = os.path.join(
98 actual_image = _download_and_open_image( 98 storage_root, actual_images_subdir,
99 os.path.join(storage_root, actual_images_subdir, 99 str(actual_image_locator) + image_suffix)
100 str(actual_image_locator) + image_suffix), 100 try:
101 actual_image_url) 101 expected_image = _download_and_open_image(
102 expected_image_file, expected_image_url)
103 except Exception:
104 logging.exception('unable to download expected_image_url %s to file %s' %
105 (expected_image_url, expected_image_file))
106 raise
107 try:
108 actual_image = _download_and_open_image(
109 actual_image_file, actual_image_url)
110 except Exception:
111 logging.exception('unable to download actual_image_url %s to file %s' %
112 (actual_image_url, actual_image_file))
113 raise
102 114
103 # Generate the diff image (absolute diff at each pixel) and 115 # Generate the diff image (absolute diff at each pixel) and
104 # max_diff_per_channel. 116 # max_diff_per_channel.
105 diff_image = _generate_image_diff(actual_image, expected_image) 117 diff_image = _generate_image_diff(actual_image, expected_image)
106 diff_histogram = diff_image.histogram() 118 diff_histogram = diff_image.histogram()
107 (diff_width, diff_height) = diff_image.size 119 (diff_width, diff_height) = diff_image.size
108 self._weighted_diff_measure = _calculate_weighted_diff_metric( 120 self._weighted_diff_measure = _calculate_weighted_diff_metric(
109 diff_histogram, diff_width * diff_height) 121 diff_histogram, diff_width * diff_height)
110 self._max_diff_per_channel = _max_per_band(diff_histogram) 122 self._max_diff_per_channel = _max_per_band(diff_histogram)
111 123
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 433
422 Args: 434 Args:
423 expected_image_locator: locator string pointing at expected image 435 expected_image_locator: locator string pointing at expected image
424 actual_image_locator: locator string pointing at actual image 436 actual_image_locator: locator string pointing at actual image
425 437
426 Returns: already-sanitized locator where the diffs between expected and 438 Returns: already-sanitized locator where the diffs between expected and
427 actual images can be found 439 actual images can be found
428 """ 440 """
429 return "%s-vs-%s" % (_sanitize_locator(expected_image_locator), 441 return "%s-vs-%s" % (_sanitize_locator(expected_image_locator),
430 _sanitize_locator(actual_image_locator)) 442 _sanitize_locator(actual_image_locator))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698