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 HTTP server for our HTML rebaseline viewer. | 9 HTTP server for our HTML rebaseline viewer. |
10 """ | 10 """ |
(...skipping 26 matching lines...) Expand all Loading... |
37 # Imports from local dir | 37 # Imports from local dir |
38 # | 38 # |
39 # pylint: disable=C0301 | 39 # pylint: disable=C0301 |
40 # Note: we import results under a different name, to avoid confusion with the | 40 # Note: we import results under a different name, to avoid confusion with the |
41 # Server.results() property. See discussion at | 41 # Server.results() property. See discussion at |
42 # https://codereview.chromium.org/195943004/diff/1/gm/rebaseline_server/server.p
y#newcode44 | 42 # https://codereview.chromium.org/195943004/diff/1/gm/rebaseline_server/server.p
y#newcode44 |
43 # pylint: enable=C0301 | 43 # pylint: enable=C0301 |
44 import compare_configs | 44 import compare_configs |
45 import compare_to_expectations | 45 import compare_to_expectations |
46 import download_actuals | 46 import download_actuals |
| 47 import imagediffdb |
47 import imagepairset | 48 import imagepairset |
48 import results as results_mod | 49 import results as results_mod |
49 | 50 |
50 PATHSPLIT_RE = re.compile('/([^/]+)/(.+)') | 51 PATHSPLIT_RE = re.compile('/([^/]+)/(.+)') |
51 | 52 |
52 # A simple dictionary of file name extensions to MIME types. The empty string | 53 # A simple dictionary of file name extensions to MIME types. The empty string |
53 # entry is used as the default when no extension was given or if the extension | 54 # entry is used as the default when no extension was given or if the extension |
54 # has no entry in this dictionary. | 55 # has no entry in this dictionary. |
55 MIME_TYPE_MAP = {'': 'application/octet-stream', | 56 MIME_TYPE_MAP = {'': 'application/octet-stream', |
56 'html': 'text/html', | 57 'html': 'text/html', |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 _create_index( | 227 _create_index( |
227 file_path=os.path.join( | 228 file_path=os.path.join( |
228 PARENT_DIRECTORY, STATIC_CONTENTS_SUBDIR, GENERATED_HTML_SUBDIR, | 229 PARENT_DIRECTORY, STATIC_CONTENTS_SUBDIR, GENERATED_HTML_SUBDIR, |
229 "index.html"), | 230 "index.html"), |
230 config_pairs=config_pairs) | 231 config_pairs=config_pairs) |
231 | 232 |
232 # Reentrant lock that must be held whenever updating EITHER of: | 233 # Reentrant lock that must be held whenever updating EITHER of: |
233 # 1. self._results | 234 # 1. self._results |
234 # 2. the expected or actual results on local disk | 235 # 2. the expected or actual results on local disk |
235 self.results_rlock = threading.RLock() | 236 self.results_rlock = threading.RLock() |
236 # self._results will be filled in by calls to update_results() | 237 |
| 238 # These will be filled in by calls to update_results() |
237 self._results = None | 239 self._results = None |
| 240 self._image_diff_db = None |
238 | 241 |
239 @property | 242 @property |
240 def results(self): | 243 def results(self): |
241 """ Returns the most recently generated results, or None if we don't have | 244 """ Returns the most recently generated results, or None if we don't have |
242 any valid results (update_results() has not completed yet). """ | 245 any valid results (update_results() has not completed yet). """ |
243 return self._results | 246 return self._results |
244 | 247 |
245 @property | 248 @property |
246 def is_exported(self): | 249 def is_exported(self): |
247 """ Returns true iff HTTP clients on other hosts are allowed to access | 250 """ Returns true iff HTTP clients on other hosts are allowed to access |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 # updated expectations into a temp directory, and leaving the rest of | 337 # updated expectations into a temp directory, and leaving the rest of |
335 # the checkout alone. This could be done using "git show", or by | 338 # the checkout alone. This could be done using "git show", or by |
336 # downloading individual expectation JSON files from | 339 # downloading individual expectation JSON files from |
337 # skia.googlesource.com . | 340 # skia.googlesource.com . |
338 if self._reload_seconds: | 341 if self._reload_seconds: |
339 logging.info( | 342 logging.info( |
340 'Updating expected GM results in %s by syncing Skia repo ...' % | 343 'Updating expected GM results in %s by syncing Skia repo ...' % |
341 compare_to_expectations.DEFAULT_EXPECTATIONS_DIR) | 344 compare_to_expectations.DEFAULT_EXPECTATIONS_DIR) |
342 _run_command(['gclient', 'sync'], TRUNK_DIRECTORY) | 345 _run_command(['gclient', 'sync'], TRUNK_DIRECTORY) |
343 | 346 |
| 347 if not self._image_diff_db: |
| 348 self._image_diff_db = imagediffdb.ImageDiffDB( |
| 349 storage_root=os.path.join( |
| 350 PARENT_DIRECTORY, STATIC_CONTENTS_SUBDIR, |
| 351 GENERATED_IMAGES_SUBDIR)) |
| 352 |
344 self._results = compare_to_expectations.ExpectationComparisons( | 353 self._results = compare_to_expectations.ExpectationComparisons( |
| 354 image_diff_db=self._image_diff_db, |
345 actuals_root=self._actuals_dir, | 355 actuals_root=self._actuals_dir, |
346 generated_images_root=os.path.join( | |
347 PARENT_DIRECTORY, STATIC_CONTENTS_SUBDIR, | |
348 GENERATED_IMAGES_SUBDIR), | |
349 diff_base_url=posixpath.join( | 356 diff_base_url=posixpath.join( |
350 os.pardir, STATIC_CONTENTS_SUBDIR, GENERATED_IMAGES_SUBDIR), | 357 os.pardir, STATIC_CONTENTS_SUBDIR, GENERATED_IMAGES_SUBDIR), |
351 builder_regex_list=self._builder_regex_list) | 358 builder_regex_list=self._builder_regex_list) |
352 | 359 |
353 json_dir = os.path.join( | 360 json_dir = os.path.join( |
354 PARENT_DIRECTORY, STATIC_CONTENTS_SUBDIR, GENERATED_JSON_SUBDIR) | 361 PARENT_DIRECTORY, STATIC_CONTENTS_SUBDIR, GENERATED_JSON_SUBDIR) |
355 if not os.path.isdir(json_dir): | 362 if not os.path.isdir(json_dir): |
356 os.makedirs(json_dir) | 363 os.makedirs(json_dir) |
357 | 364 |
358 for config_pair in self._config_pairs: | 365 for config_pair in self._config_pairs: |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 json_filename=args.json_filename, | 700 json_filename=args.json_filename, |
694 gm_summaries_bucket=args.gm_summaries_bucket, | 701 gm_summaries_bucket=args.gm_summaries_bucket, |
695 port=args.port, export=args.export, editable=args.editable, | 702 port=args.port, export=args.export, editable=args.editable, |
696 reload_seconds=args.reload, config_pairs=config_pairs, | 703 reload_seconds=args.reload, config_pairs=config_pairs, |
697 builder_regex_list=args.builders) | 704 builder_regex_list=args.builders) |
698 _SERVER.run() | 705 _SERVER.run() |
699 | 706 |
700 | 707 |
701 if __name__ == '__main__': | 708 if __name__ == '__main__': |
702 main() | 709 main() |
OLD | NEW |