Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Side by Side Diff: gm/rebaseline_server/server.py

Issue 208243003: rebaseline_server: rename results.py to compare_to_expectations.py (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
37 TOOLS_DIRECTORY = os.path.join(TRUNK_DIRECTORY, 'tools') 37 TOOLS_DIRECTORY = os.path.join(TRUNK_DIRECTORY, 'tools')
38 if TOOLS_DIRECTORY not in sys.path: 38 if TOOLS_DIRECTORY not in sys.path:
39 sys.path.append(TOOLS_DIRECTORY) 39 sys.path.append(TOOLS_DIRECTORY)
40 import svn 40 import svn
41 41
42 # Imports from local dir 42 # Imports from local dir
43 # 43 #
44 # Note: we import results under a different name, to avoid confusion with the 44 # Note: we import results under a different name, to avoid confusion with the
45 # Server.results() property. See discussion at 45 # Server.results() property. See discussion at
46 # https://codereview.chromium.org/195943004/diff/1/gm/rebaseline_server/server.p y#newcode44 46 # https://codereview.chromium.org/195943004/diff/1/gm/rebaseline_server/server.p y#newcode44
47 import compare_to_expectations
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',
57 'css': 'text/css', 58 'css': 'text/css',
58 'png': 'image/png', 59 'png': 'image/png',
59 'js': 'application/javascript', 60 'js': 'application/javascript',
60 'json': 'application/json' 61 'json': 'application/json'
61 } 62 }
62 63
63 # Keys that server.py uses to create the toplevel content header. 64 # Keys that server.py uses to create the toplevel content header.
64 # NOTE: Keep these in sync with static/constants.js 65 # NOTE: Keep these in sync with static/constants.js
65 KEY__EDITS__MODIFICATIONS = 'modifications' 66 KEY__EDITS__MODIFICATIONS = 'modifications'
66 KEY__EDITS__OLD_RESULTS_HASH = 'oldResultsHash' 67 KEY__EDITS__OLD_RESULTS_HASH = 'oldResultsHash'
67 KEY__EDITS__OLD_RESULTS_TYPE = 'oldResultsType' 68 KEY__EDITS__OLD_RESULTS_TYPE = 'oldResultsType'
68 69
69 DEFAULT_ACTUALS_DIR = results_mod.DEFAULT_ACTUALS_DIR 70 DEFAULT_ACTUALS_DIR = compare_to_expectations.DEFAULT_ACTUALS_DIR
70 DEFAULT_ACTUALS_REPO_REVISION = 'HEAD' 71 DEFAULT_ACTUALS_REPO_REVISION = 'HEAD'
71 DEFAULT_ACTUALS_REPO_URL = 'http://skia-autogen.googlecode.com/svn/gm-actual' 72 DEFAULT_ACTUALS_REPO_URL = 'http://skia-autogen.googlecode.com/svn/gm-actual'
72 DEFAULT_PORT = 8888 73 DEFAULT_PORT = 8888
73 74
74 # Directory within which the server will serve out static files. 75 # Directory within which the server will serve out static files.
75 STATIC_CONTENTS_SUBDIR = 'static' # within PARENT_DIR 76 STATIC_CONTENTS_SUBDIR = 'static' # within PARENT_DIR
76 GENERATED_IMAGES_SUBDIR = 'generated-images' # within STATIC_CONTENTS_SUBDIR 77 GENERATED_IMAGES_SUBDIR = 'generated-images' # within STATIC_CONTENTS_SUBDIR
77 78
78 # How often (in seconds) clients should reload while waiting for initial 79 # How often (in seconds) clients should reload while waiting for initial
79 # results to load. 80 # results to load.
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 # Because the Skia repo is moving from SVN to git, and git does not 227 # Because the Skia repo is moving from SVN to git, and git does not
227 # support updating a single directory tree, we have to update the entire 228 # support updating a single directory tree, we have to update the entire
228 # repo checkout. 229 # repo checkout.
229 # 230 #
230 # Because Skia uses depot_tools, we have to update using "gclient sync" 231 # Because Skia uses depot_tools, we have to update using "gclient sync"
231 # instead of raw git (or SVN) update. Happily, this will work whether 232 # instead of raw git (or SVN) update. Happily, this will work whether
232 # the checkout was created using git or SVN. 233 # the checkout was created using git or SVN.
233 if self._reload_seconds: 234 if self._reload_seconds:
234 logging.info( 235 logging.info(
235 'Updating expected GM results in %s by syncing Skia repo ...' % 236 'Updating expected GM results in %s by syncing Skia repo ...' %
236 results_mod.DEFAULT_EXPECTATIONS_DIR) 237 compare_to_expectations.DEFAULT_EXPECTATIONS_DIR)
237 _run_command(['gclient', 'sync'], TRUNK_DIRECTORY) 238 _run_command(['gclient', 'sync'], TRUNK_DIRECTORY)
238 239
239 self._results = results_mod.Results( 240 self._results = compare_to_expectations.Results(
240 actuals_root=self._actuals_dir, 241 actuals_root=self._actuals_dir,
241 generated_images_root=os.path.join( 242 generated_images_root=os.path.join(
242 PARENT_DIRECTORY, STATIC_CONTENTS_SUBDIR, 243 PARENT_DIRECTORY, STATIC_CONTENTS_SUBDIR,
243 GENERATED_IMAGES_SUBDIR), 244 GENERATED_IMAGES_SUBDIR),
244 diff_base_url=posixpath.join( 245 diff_base_url=posixpath.join(
245 os.pardir, STATIC_CONTENTS_SUBDIR, GENERATED_IMAGES_SUBDIR)) 246 os.pardir, STATIC_CONTENTS_SUBDIR, GENERATED_IMAGES_SUBDIR))
246 247
247 def _result_loader(self, reload_seconds=0): 248 def _result_loader(self, reload_seconds=0):
248 """ Call self.update_results(), either once or periodically. 249 """ Call self.update_results(), either once or periodically.
249 250
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 399
399 { 400 {
400 KEY__EDITS__OLD_RESULTS_TYPE: 'all', # type of results that the client 401 KEY__EDITS__OLD_RESULTS_TYPE: 'all', # type of results that the client
401 # loaded and then made 402 # loaded and then made
402 # modifications to 403 # modifications to
403 KEY__EDITS__OLD_RESULTS_HASH: 39850913, # hash of results when the client 404 KEY__EDITS__OLD_RESULTS_HASH: 39850913, # hash of results when the client
404 # loaded them (ensures that the 405 # loaded them (ensures that the
405 # client and server apply 406 # client and server apply
406 # modifications to the same base) 407 # modifications to the same base)
407 KEY__EDITS__MODIFICATIONS: [ 408 KEY__EDITS__MODIFICATIONS: [
408 # as needed by results_mod.edit_expectations() 409 # as needed by compare_to_expectations.edit_expectations()
409 ... 410 ...
410 ], 411 ],
411 } 412 }
412 413
413 Raises an Exception if there were any problems. 414 Raises an Exception if there were any problems.
414 """ 415 """
415 if not _SERVER.is_editable: 416 if not _SERVER.is_editable:
416 raise Exception('this server is not running in --editable mode') 417 raise Exception('this server is not running in --editable mode')
417 418
418 content_type = self.headers[_HTTP_HEADER_CONTENT_TYPE] 419 content_type = self.headers[_HTTP_HEADER_CONTENT_TYPE]
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 _SERVER = Server(actuals_dir=args.actuals_dir, 541 _SERVER = Server(actuals_dir=args.actuals_dir,
541 actuals_repo_revision=args.actuals_revision, 542 actuals_repo_revision=args.actuals_revision,
542 actuals_repo_url=args.actuals_repo, 543 actuals_repo_url=args.actuals_repo,
543 port=args.port, export=args.export, editable=args.editable, 544 port=args.port, export=args.export, editable=args.editable,
544 reload_seconds=args.reload) 545 reload_seconds=args.reload)
545 _SERVER.run() 546 _SERVER.run()
546 547
547 548
548 if __name__ == '__main__': 549 if __name__ == '__main__':
549 main() 550 main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698