X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fthird_party%2Fskia%2Fgm%2Frebaseline_server%2Fserver.py;h=6062aed641e1f9581ccc852eaf9f656265682bef;hb=3545e9f2671f595d2a2f3ee75ca0393b01e35ef6;hp=8277c46de7aae892e18528fc224e017915a5a2fe;hpb=7d210d4c7e9ba36e635eabc5b5780495f8a63292;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/third_party/skia/gm/rebaseline_server/server.py b/src/third_party/skia/gm/rebaseline_server/server.py index 8277c46..6062aed 100755 --- a/src/third_party/skia/gm/rebaseline_server/server.py +++ b/src/third_party/skia/gm/rebaseline_server/server.py @@ -27,7 +27,7 @@ import urllib import urlparse # Must fix up PYTHONPATH before importing from within Skia -import fix_pythonpath # pylint: disable=W0611 +import rs_fixpypath # pylint: disable=W0611 # Imports from within Skia from py.utils import gs_utils @@ -48,6 +48,8 @@ import download_actuals import imagediffdb import imagepairset import results as results_mod +import writable_expectations as writable_expectations_mod + PATHSPLIT_RE = re.compile('/([^/]+)/(.+)') @@ -67,6 +69,9 @@ MIME_TYPE_MAP = {'': 'application/octet-stream', KEY__EDITS__MODIFICATIONS = 'modifications' KEY__EDITS__OLD_RESULTS_HASH = 'oldResultsHash' KEY__EDITS__OLD_RESULTS_TYPE = 'oldResultsType' +KEY__LIVE_EDITS__MODIFICATIONS = 'modifications' +KEY__LIVE_EDITS__SET_A_DESCRIPTIONS = 'setA' +KEY__LIVE_EDITS__SET_B_DESCRIPTIONS = 'setB' DEFAULT_ACTUALS_DIR = results_mod.DEFAULT_ACTUALS_DIR DEFAULT_GM_SUMMARIES_BUCKET = download_actuals.GM_SUMMARIES_BUCKET @@ -597,8 +602,8 @@ class HTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): download_all_images = ( param_dict.get(LIVE_PARAM__DOWNLOAD_ONLY_DIFFERING, [''])[0].lower() not in ['1', 'true']) - setA_dirs = param_dict[LIVE_PARAM__SET_A_DIR] - setB_dirs = param_dict[LIVE_PARAM__SET_B_DIR] + setA_dir = param_dict[LIVE_PARAM__SET_A_DIR][0] + setB_dir = param_dict[LIVE_PARAM__SET_B_DIR][0] setA_section = self._validate_summary_section( param_dict.get(LIVE_PARAM__SET_A_SECTION, [None])[0]) setB_section = self._validate_summary_section( @@ -608,18 +613,18 @@ class HTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): # the left (setA). if ((setA_section == gm_json.JSONKEY_ACTUALRESULTS) and (setB_section == gm_json.JSONKEY_EXPECTEDRESULTS)): - setA_dirs, setB_dirs = setB_dirs, setA_dirs + setA_dir, setB_dir = setB_dir, setA_dir setA_section, setB_section = setB_section, setA_section # Are we comparing some actuals against expectations stored in the repo? # If so, we can allow the user to submit new baselines. is_editable = ( (setA_section == gm_json.JSONKEY_EXPECTEDRESULTS) and - (setA_dirs[0].startswith(compare_rendered_pictures.REPO_URL_PREFIX)) and + (setA_dir.startswith(compare_rendered_pictures.REPO_URL_PREFIX)) and (setB_section == gm_json.JSONKEY_ACTUALRESULTS)) results_obj = compare_rendered_pictures.RenderedPicturesComparisons( - setA_dirs=setA_dirs, setB_dirs=setB_dirs, + setA_dir=setA_dir, setB_dir=setB_dir, setA_section=setA_section, setB_section=setB_section, image_diff_db=_SERVER.image_diff_db, diff_base_url='/static/generated-images', @@ -685,11 +690,11 @@ class HTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): normpath = posixpath.normpath(self.path) dispatchers = { '/edits': self.do_POST_edits, + '/live-edits': self.do_POST_live_edits, } try: dispatcher = dispatchers[normpath] dispatcher() - self.send_response(200) except: self.send_error(404) raise @@ -749,6 +754,47 @@ class HTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): # We can do this in a separate thread; we should return our success message # to the UI as soon as possible. thread.start_new_thread(_SERVER.update_results, (True,)) + self.send_response(200) + + def do_POST_live_edits(self): + """ Handle a POST request with modifications to SKP expectations, in this + format: + + { + KEY__LIVE_EDITS__SET_A_DESCRIPTIONS: { + # setA descriptions from the original data + }, + KEY__LIVE_EDITS__SET_B_DESCRIPTIONS: { + # setB descriptions from the original data + }, + KEY__LIVE_EDITS__MODIFICATIONS: [ + # as needed by writable_expectations.modify() + ], + } + + Raises an Exception if there were any problems. + """ + content_type = self.headers[_HTTP_HEADER_CONTENT_TYPE] + if content_type != 'application/json;charset=UTF-8': + raise Exception('unsupported %s [%s]' % ( + _HTTP_HEADER_CONTENT_TYPE, content_type)) + + content_length = int(self.headers[_HTTP_HEADER_CONTENT_LENGTH]) + json_data = self.rfile.read(content_length) + data = json.loads(json_data) + logging.debug('do_POST_live_edits: received new GM expectations data [%s]' % + data) + with writable_expectations_mod.WritableExpectations( + data[KEY__LIVE_EDITS__SET_A_DESCRIPTIONS]) as writable_expectations: + writable_expectations.modify(data[KEY__LIVE_EDITS__MODIFICATIONS]) + diffs = writable_expectations.get_diffs() + # TODO(stephana): Move to a simpler web framework so we don't have to + # call these functions. See http://skbug.com/2856 ('rebaseline_server: + # Refactor server to use a simple web framework') + self.send_response(200) + self.send_header('Content-type', 'text/plain') + self.end_headers() + self.wfile.write(diffs) def redirect_to(self, url): """ Redirect the HTTP client to a different url.