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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 """ | 167 """ |
168 key = (expected_image_locator, actual_image_locator) | 168 key = (expected_image_locator, actual_image_locator) |
169 if not key in self._diff_dict: | 169 if not key in self._diff_dict: |
170 try: | 170 try: |
171 new_diff_record = DiffRecord( | 171 new_diff_record = DiffRecord( |
172 self._storage_root, | 172 self._storage_root, |
173 expected_image_url=expected_image_url, | 173 expected_image_url=expected_image_url, |
174 expected_image_locator=expected_image_locator, | 174 expected_image_locator=expected_image_locator, |
175 actual_image_url=actual_image_url, | 175 actual_image_url=actual_image_url, |
176 actual_image_locator=actual_image_locator) | 176 actual_image_locator=actual_image_locator) |
177 except: | 177 except Exception: |
178 logging.exception('got exception while creating new DiffRecord') | 178 logging.exception('got exception while creating new DiffRecord') |
179 return | 179 return |
180 self._diff_dict[key] = new_diff_record | 180 self._diff_dict[key] = new_diff_record |
181 | 181 |
182 def get_diff_record(self, expected_image_locator, actual_image_locator): | 182 def get_diff_record(self, expected_image_locator, actual_image_locator): |
183 """Returns the DiffRecord for this image pair. | 183 """Returns the DiffRecord for this image pair. |
184 | 184 |
185 Raises a KeyError if we don't have a DiffRecord for this image pair. | 185 Raises a KeyError if we don't have a DiffRecord for this image pair. |
186 """ | 186 """ |
187 key = (expected_image_locator, actual_image_locator) | 187 key = (expected_image_locator, actual_image_locator) |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 and actual_image. | 318 and actual_image. |
319 | 319 |
320 Args: | 320 Args: |
321 expected_image_locator: locator string pointing at expected image | 321 expected_image_locator: locator string pointing at expected image |
322 actual_image_locator: locator string pointing at actual image | 322 actual_image_locator: locator string pointing at actual image |
323 | 323 |
324 Returns: locator where the diffs between expected and actual images can be | 324 Returns: locator where the diffs between expected and actual images can be |
325 found | 325 found |
326 """ | 326 """ |
327 return "%s-vs-%s" % (expected_image_locator, actual_image_locator) | 327 return "%s-vs-%s" % (expected_image_locator, actual_image_locator) |
OLD | NEW |