OLD | NEW |
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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 key = (expected_image_locator, actual_image_locator) | 261 key = (expected_image_locator, actual_image_locator) |
262 if not key in self._diff_dict: | 262 if not key in self._diff_dict: |
263 try: | 263 try: |
264 new_diff_record = DiffRecord( | 264 new_diff_record = DiffRecord( |
265 self._storage_root, | 265 self._storage_root, |
266 expected_image_url=expected_image_url, | 266 expected_image_url=expected_image_url, |
267 expected_image_locator=expected_image_locator, | 267 expected_image_locator=expected_image_locator, |
268 actual_image_url=actual_image_url, | 268 actual_image_url=actual_image_url, |
269 actual_image_locator=actual_image_locator) | 269 actual_image_locator=actual_image_locator) |
270 except Exception: | 270 except Exception: |
271 logging.exception('got exception while creating new DiffRecord') | 271 # If we can't create a real DiffRecord for this (expected, actual) pair, |
272 return | 272 # store None and the UI will show whatever information we DO have. |
| 273 # Fixes http://skbug.com/2368 . |
| 274 logging.exception( |
| 275 'got exception while creating a DiffRecord for ' |
| 276 'expected_image_url=%s , actual_image_url=%s; returning None' % ( |
| 277 expected_image_url, actual_image_url)) |
| 278 new_diff_record = None |
273 self._diff_dict[key] = new_diff_record | 279 self._diff_dict[key] = new_diff_record |
274 | 280 |
275 def get_diff_record(self, expected_image_locator, actual_image_locator): | 281 def get_diff_record(self, expected_image_locator, actual_image_locator): |
276 """Returns the DiffRecord for this image pair. | 282 """Returns the DiffRecord for this image pair. |
277 | 283 |
278 Raises a KeyError if we don't have a DiffRecord for this image pair. | 284 Raises a KeyError if we don't have a DiffRecord for this image pair. |
279 """ | 285 """ |
280 key = (_sanitize_locator(expected_image_locator), | 286 key = (_sanitize_locator(expected_image_locator), |
281 _sanitize_locator(actual_image_locator)) | 287 _sanitize_locator(actual_image_locator)) |
282 return self._diff_dict[key] | 288 return self._diff_dict[key] |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 | 442 |
437 Args: | 443 Args: |
438 expected_image_locator: locator string pointing at expected image | 444 expected_image_locator: locator string pointing at expected image |
439 actual_image_locator: locator string pointing at actual image | 445 actual_image_locator: locator string pointing at actual image |
440 | 446 |
441 Returns: already-sanitized locator where the diffs between expected and | 447 Returns: already-sanitized locator where the diffs between expected and |
442 actual images can be found | 448 actual images can be found |
443 """ | 449 """ |
444 return "%s-vs-%s" % (_sanitize_locator(expected_image_locator), | 450 return "%s-vs-%s" % (_sanitize_locator(expected_image_locator), |
445 _sanitize_locator(actual_image_locator)) | 451 _sanitize_locator(actual_image_locator)) |
OLD | NEW |