| 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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 return self._gs | 342 return self._gs |
| 343 | 343 |
| 344 @property | 344 @property |
| 345 def is_exported(self): | 345 def is_exported(self): |
| 346 """ Returns true iff HTTP clients on other hosts are allowed to access | 346 """ Returns true iff HTTP clients on other hosts are allowed to access |
| 347 this server. """ | 347 this server. """ |
| 348 return self._export | 348 return self._export |
| 349 | 349 |
| 350 @property | 350 @property |
| 351 def is_editable(self): | 351 def is_editable(self): |
| 352 """ True iff HTTP clients are allowed to submit new GM baselines. """ | 352 """ True iff HTTP clients are allowed to submit new GM baselines. |
| 353 |
| 354 TODO(epoger): This only pertains to GM baselines; SKP baselines are |
| 355 editable whenever expectations vs actuals are shown. |
| 356 Once we move the GM baselines to use the same code as the SKP baselines, |
| 357 we can delete this property. |
| 358 """ |
| 353 return self._editable | 359 return self._editable |
| 354 | 360 |
| 355 @property | 361 @property |
| 356 def reload_seconds(self): | 362 def reload_seconds(self): |
| 357 """ Returns the result reload period in seconds, or 0 if we don't reload | 363 """ Returns the result reload period in seconds, or 0 if we don't reload |
| 358 results. """ | 364 results. """ |
| 359 return self._reload_seconds | 365 return self._reload_seconds |
| 360 | 366 |
| 361 def update_results(self, invalidate=False): | 367 def update_results(self, invalidate=False): |
| 362 """ Create or update self._results, based on the latest expectations and | 368 """ Create or update self._results, based on the latest expectations and |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 param_dict = urlparse.parse_qs(url_remainder) | 596 param_dict = urlparse.parse_qs(url_remainder) |
| 591 download_all_images = ( | 597 download_all_images = ( |
| 592 param_dict.get(LIVE_PARAM__DOWNLOAD_ONLY_DIFFERING, [''])[0].lower() | 598 param_dict.get(LIVE_PARAM__DOWNLOAD_ONLY_DIFFERING, [''])[0].lower() |
| 593 not in ['1', 'true']) | 599 not in ['1', 'true']) |
| 594 setA_dirs = param_dict[LIVE_PARAM__SET_A_DIR] | 600 setA_dirs = param_dict[LIVE_PARAM__SET_A_DIR] |
| 595 setB_dirs = param_dict[LIVE_PARAM__SET_B_DIR] | 601 setB_dirs = param_dict[LIVE_PARAM__SET_B_DIR] |
| 596 setA_section = self._validate_summary_section( | 602 setA_section = self._validate_summary_section( |
| 597 param_dict.get(LIVE_PARAM__SET_A_SECTION, [None])[0]) | 603 param_dict.get(LIVE_PARAM__SET_A_SECTION, [None])[0]) |
| 598 setB_section = self._validate_summary_section( | 604 setB_section = self._validate_summary_section( |
| 599 param_dict.get(LIVE_PARAM__SET_B_SECTION, [None])[0]) | 605 param_dict.get(LIVE_PARAM__SET_B_SECTION, [None])[0]) |
| 606 |
| 607 # If the sets show expectations vs actuals, always show expectations on |
| 608 # the left (setA). |
| 609 if ((setA_section == gm_json.JSONKEY_ACTUALRESULTS) and |
| 610 (setB_section == gm_json.JSONKEY_EXPECTEDRESULTS)): |
| 611 setA_dirs, setB_dirs = setB_dirs, setA_dirs |
| 612 setA_section, setB_section = setB_section, setA_section |
| 613 |
| 614 # Are we comparing some actuals against expectations stored in the repo? |
| 615 # If so, we can allow the user to submit new baselines. |
| 616 is_editable = ( |
| 617 (setA_section == gm_json.JSONKEY_EXPECTEDRESULTS) and |
| 618 (setA_dirs[0].startswith(compare_rendered_pictures.REPO_URL_PREFIX)) and |
| 619 (setB_section == gm_json.JSONKEY_ACTUALRESULTS)) |
| 620 |
| 600 results_obj = compare_rendered_pictures.RenderedPicturesComparisons( | 621 results_obj = compare_rendered_pictures.RenderedPicturesComparisons( |
| 601 setA_dirs=setA_dirs, setB_dirs=setB_dirs, | 622 setA_dirs=setA_dirs, setB_dirs=setB_dirs, |
| 602 setA_section=setA_section, setB_section=setB_section, | 623 setA_section=setA_section, setB_section=setB_section, |
| 603 image_diff_db=_SERVER.image_diff_db, | 624 image_diff_db=_SERVER.image_diff_db, |
| 604 diff_base_url='/static/generated-images', | 625 diff_base_url='/static/generated-images', |
| 605 gs=_SERVER.gs, truncate_results=_SERVER.truncate_results, | 626 gs=_SERVER.gs, truncate_results=_SERVER.truncate_results, |
| 606 prefetch_only=prefetch_only, download_all_images=download_all_images) | 627 prefetch_only=prefetch_only, download_all_images=download_all_images) |
| 607 if prefetch_only: | 628 if prefetch_only: |
| 608 self.send_response(200) | 629 self.send_response(200) |
| 609 else: | 630 else: |
| 610 self.send_json_dict(results_obj.get_packaged_results_of_type( | 631 self.send_json_dict(results_obj.get_packaged_results_of_type( |
| 611 results_type=results_mod.KEY__HEADER__RESULTS_ALL)) | 632 results_type=results_mod.KEY__HEADER__RESULTS_ALL, |
| 633 is_editable=is_editable)) |
| 612 | 634 |
| 613 def do_GET_live_results(self, url_remainder): | 635 def do_GET_live_results(self, url_remainder): |
| 614 """ Handle a GET request for live-generated image diff data. | 636 """ Handle a GET request for live-generated image diff data. |
| 615 | 637 |
| 616 Args: | 638 Args: |
| 617 url_remainder: string indicating which image diffs to generate | 639 url_remainder: string indicating which image diffs to generate |
| 618 """ | 640 """ |
| 619 logging.debug('do_GET_live_results: url_remainder="%s"' % url_remainder) | 641 logging.debug('do_GET_live_results: url_remainder="%s"' % url_remainder) |
| 620 self._get_live_results_or_prefetch( | 642 self._get_live_results_or_prefetch( |
| 621 url_remainder=url_remainder, prefetch_only=False) | 643 url_remainder=url_remainder, prefetch_only=False) |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 parser.add_argument('--builders', metavar='BUILDER_REGEX', nargs='+', | 837 parser.add_argument('--builders', metavar='BUILDER_REGEX', nargs='+', |
| 816 help=('Only process builders matching these regular ' | 838 help=('Only process builders matching these regular ' |
| 817 'expressions. If unspecified, process all ' | 839 'expressions. If unspecified, process all ' |
| 818 'builders.')) | 840 'builders.')) |
| 819 parser.add_argument('--compare-configs', action='store_true', | 841 parser.add_argument('--compare-configs', action='store_true', |
| 820 help=('In addition to generating differences between ' | 842 help=('In addition to generating differences between ' |
| 821 'expectations and actuals, also generate ' | 843 'expectations and actuals, also generate ' |
| 822 'differences between these config pairs: ' | 844 'differences between these config pairs: ' |
| 823 + str(CONFIG_PAIRS_TO_COMPARE))) | 845 + str(CONFIG_PAIRS_TO_COMPARE))) |
| 824 parser.add_argument('--editable', action='store_true', | 846 parser.add_argument('--editable', action='store_true', |
| 825 help=('Allow HTTP clients to submit new GM baselines.')) | 847 help=('Allow HTTP clients to submit new GM baselines; ' |
| 848 'SKP baselines can be edited regardless of this ' |
| 849 'setting.')) |
| 826 parser.add_argument('--export', action='store_true', | 850 parser.add_argument('--export', action='store_true', |
| 827 help=('Instead of only allowing access from HTTP clients ' | 851 help=('Instead of only allowing access from HTTP clients ' |
| 828 'on localhost, allow HTTP clients on other hosts ' | 852 'on localhost, allow HTTP clients on other hosts ' |
| 829 'to access this server. WARNING: doing so will ' | 853 'to access this server. WARNING: doing so will ' |
| 830 'allow users on other hosts to modify your ' | 854 'allow users on other hosts to modify your ' |
| 831 'GM expectations, if combined with --editable.')) | 855 'GM expectations, if combined with --editable.')) |
| 832 parser.add_argument('--gm-summaries-bucket', | 856 parser.add_argument('--gm-summaries-bucket', |
| 833 help=('Google Cloud Storage bucket to download ' | 857 help=('Google Cloud Storage bucket to download ' |
| 834 'JSON_FILENAME files from. ' | 858 'JSON_FILENAME files from. ' |
| 835 'Defaults to %(default)s ; if set to ' | 859 'Defaults to %(default)s ; if set to ' |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 874 reload_seconds=args.reload, config_pairs=config_pairs, | 898 reload_seconds=args.reload, config_pairs=config_pairs, |
| 875 builder_regex_list=args.builders, boto_file_path=args.boto, | 899 builder_regex_list=args.builders, boto_file_path=args.boto, |
| 876 imagediffdb_threads=args.threads) | 900 imagediffdb_threads=args.threads) |
| 877 if args.truncate: | 901 if args.truncate: |
| 878 _SERVER.truncate_results = True | 902 _SERVER.truncate_results = True |
| 879 _SERVER.run() | 903 _SERVER.run() |
| 880 | 904 |
| 881 | 905 |
| 882 if __name__ == '__main__': | 906 if __name__ == '__main__': |
| 883 main() | 907 main() |
| OLD | NEW |