Index: gm/rebaseline_server/server.py |
diff --git a/gm/rebaseline_server/server.py b/gm/rebaseline_server/server.py |
index b3c78637f5339a6f1673160c22d90cab38769338..f2ba8227f5b760c92d549a0c3c070aed31bb49f4 100755 |
--- a/gm/rebaseline_server/server.py |
+++ b/gm/rebaseline_server/server.py |
@@ -269,7 +269,9 @@ class Server(object): |
at all, just compare to whatever files are already in actuals_dir |
port: which TCP port to listen on for HTTP requests |
export: whether to allow HTTP clients on other hosts to access this server |
- editable: whether HTTP clients are allowed to submit new baselines |
+ editable: whether HTTP clients are allowed to submit new GM baselines |
+ (SKP baseline modifications are performed using an entirely different |
+ mechanism, not affected by this parameter) |
reload_seconds: polling interval with which to check for new results; |
if 0, don't check for new results at all |
config_pairs: List of (string, string) tuples; for each tuple, compare |
@@ -344,7 +346,7 @@ class Server(object): |
@property |
def is_editable(self): |
- """ Returns true iff HTTP clients are allowed to submit new baselines. """ |
+ """ True iff HTTP clients are allowed to submit new GM baselines. """ |
return self._editable |
@property |
@@ -575,6 +577,35 @@ class HTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): |
} |
self.send_json_dict(response_dict) |
+ def _get_live_results_or_prefetch(self, url_remainder, prefetch_only=False): |
+ """ Handle a GET request for live-generated image diff data. |
+ |
+ Args: |
+ url_remainder: string indicating which image diffs to generate |
+ prefetch_only: if True, the user isn't waiting around for results |
+ """ |
+ param_dict = urlparse.parse_qs(url_remainder) |
+ download_all_images = ( |
+ param_dict.get(LIVE_PARAM__DOWNLOAD_ONLY_DIFFERING, [''])[0].lower() |
+ not in ['1', 'true']) |
+ setA_section = self._validate_summary_section( |
+ param_dict.get(LIVE_PARAM__SET_A_SECTION, [None])[0]) |
+ setB_section = self._validate_summary_section( |
+ param_dict.get(LIVE_PARAM__SET_B_SECTION, [None])[0]) |
+ results_obj = compare_rendered_pictures.RenderedPicturesComparisons( |
+ setA_dirs=param_dict[LIVE_PARAM__SET_A_DIR], |
+ setB_dirs=param_dict[LIVE_PARAM__SET_B_DIR], |
+ setA_section=setA_section, setB_section=setB_section, |
+ image_diff_db=_SERVER.image_diff_db, |
+ diff_base_url='/static/generated-images', |
+ gs=_SERVER.gs, truncate_results=_SERVER.truncate_results, |
+ prefetch_only=prefetch_only, download_all_images=download_all_images) |
+ if prefetch_only: |
+ self.send_response(200) |
+ else: |
+ self.send_json_dict(results_obj.get_packaged_results_of_type( |
+ results_mod.KEY__HEADER__RESULTS_ALL)) |
+ |
def do_GET_live_results(self, url_remainder): |
""" Handle a GET request for live-generated image diff data. |
@@ -582,11 +613,8 @@ class HTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): |
url_remainder: string indicating which image diffs to generate |
""" |
logging.debug('do_GET_live_results: url_remainder="%s"' % url_remainder) |
- param_dict = urlparse.parse_qs(url_remainder) |
- results_obj = self._call_compare_rendered_pictures( |
- param_dict=param_dict, prefetch_only=False) |
- self.send_json_dict(results_obj.get_packaged_results_of_type( |
- results_mod.KEY__HEADER__RESULTS_ALL)) |
+ self._get_live_results_or_prefetch( |
+ url_remainder=url_remainder, prefetch_only=False) |
def do_GET_prefetch_results(self, url_remainder): |
""" Prefetch image diff data for a future do_GET_live_results() call. |
@@ -595,10 +623,8 @@ class HTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): |
url_remainder: string indicating which image diffs to generate |
""" |
logging.debug('do_GET_prefetch_results: url_remainder="%s"' % url_remainder) |
- param_dict = urlparse.parse_qs(url_remainder) |
- self._call_compare_rendered_pictures( |
- param_dict=param_dict, prefetch_only=True) |
- self.send_response(200) |
+ self._get_live_results_or_prefetch( |
+ url_remainder=url_remainder, prefetch_only=True) |
def do_GET_static(self, path): |
""" Handle a GET request for a file under STATIC_CONTENTS_SUBDIR . |
@@ -745,32 +771,6 @@ class HTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): |
self.end_headers() |
json.dump(json_dict, self.wfile) |
- def _call_compare_rendered_pictures(self, param_dict, prefetch_only): |
- """Instantiates RenderedPicturesComparisons object to serve a GET request. |
- |
- Args: |
- param_dict: dictionary of URL parameters |
- prefetch_only: parameter to pass into RenderedPicturesComparisons |
- constructor |
- |
- Returns: a reference to the new RenderedPicturesComparisons object. |
- """ |
- download_all_images = ( |
- param_dict.get(LIVE_PARAM__DOWNLOAD_ONLY_DIFFERING, [''])[0].lower() |
- not in ['1', 'true']) |
- setA_section = self._validate_summary_section( |
- param_dict.get(LIVE_PARAM__SET_A_SECTION, [None])[0]) |
- setB_section = self._validate_summary_section( |
- param_dict.get(LIVE_PARAM__SET_B_SECTION, [None])[0]) |
- return compare_rendered_pictures.RenderedPicturesComparisons( |
- setA_dirs=param_dict[LIVE_PARAM__SET_A_DIR], |
- setB_dirs=param_dict[LIVE_PARAM__SET_B_DIR], |
- setA_section=setA_section, setB_section=setB_section, |
- image_diff_db=_SERVER.image_diff_db, |
- diff_base_url='/static/generated-images', |
- gs=_SERVER.gs, truncate_results=_SERVER.truncate_results, |
- prefetch_only=prefetch_only, download_all_images=download_all_images) |
- |
def _validate_summary_section(self, section_name): |
"""Validates the section we have been requested to read within JSON summary. |
@@ -818,7 +818,7 @@ def main(): |
'differences between these config pairs: ' |
+ str(CONFIG_PAIRS_TO_COMPARE))) |
parser.add_argument('--editable', action='store_true', |
- help=('Allow HTTP clients to submit new baselines.')) |
+ help=('Allow HTTP clients to submit new GM baselines.')) |
parser.add_argument('--export', action='store_true', |
help=('Instead of only allowing access from HTTP clients ' |
'on localhost, allow HTTP clients on other hosts ' |