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 30 matching lines...) Expand all Loading... |
41 import svn | 41 import svn |
42 if GM_DIRECTORY not in sys.path: | 42 if GM_DIRECTORY not in sys.path: |
43 sys.path.append(GM_DIRECTORY) | 43 sys.path.append(GM_DIRECTORY) |
44 import gm_json | 44 import gm_json |
45 | 45 |
46 # Imports from local dir | 46 # Imports from local dir |
47 # | 47 # |
48 # Note: we import results under a different name, to avoid confusion with the | 48 # Note: we import results under a different name, to avoid confusion with the |
49 # Server.results() property. See discussion at | 49 # Server.results() property. See discussion at |
50 # https://codereview.chromium.org/195943004/diff/1/gm/rebaseline_server/server.p
y#newcode44 | 50 # https://codereview.chromium.org/195943004/diff/1/gm/rebaseline_server/server.p
y#newcode44 |
| 51 import compare_to_expectations |
51 import imagepairset | 52 import imagepairset |
52 import results as results_mod | 53 import results as results_mod |
53 | 54 |
54 PATHSPLIT_RE = re.compile('/([^/]+)/(.+)') | 55 PATHSPLIT_RE = re.compile('/([^/]+)/(.+)') |
55 | 56 |
56 # A simple dictionary of file name extensions to MIME types. The empty string | 57 # A simple dictionary of file name extensions to MIME types. The empty string |
57 # entry is used as the default when no extension was given or if the extension | 58 # entry is used as the default when no extension was given or if the extension |
58 # has no entry in this dictionary. | 59 # has no entry in this dictionary. |
59 MIME_TYPE_MAP = {'': 'application/octet-stream', | 60 MIME_TYPE_MAP = {'': 'application/octet-stream', |
60 'html': 'text/html', | 61 'html': 'text/html', |
61 'css': 'text/css', | 62 'css': 'text/css', |
62 'png': 'image/png', | 63 'png': 'image/png', |
63 'js': 'application/javascript', | 64 'js': 'application/javascript', |
64 'json': 'application/json' | 65 'json': 'application/json' |
65 } | 66 } |
66 | 67 |
67 # Keys that server.py uses to create the toplevel content header. | 68 # Keys that server.py uses to create the toplevel content header. |
68 # NOTE: Keep these in sync with static/constants.js | 69 # NOTE: Keep these in sync with static/constants.js |
69 KEY__EDITS__MODIFICATIONS = 'modifications' | 70 KEY__EDITS__MODIFICATIONS = 'modifications' |
70 KEY__EDITS__OLD_RESULTS_HASH = 'oldResultsHash' | 71 KEY__EDITS__OLD_RESULTS_HASH = 'oldResultsHash' |
71 KEY__EDITS__OLD_RESULTS_TYPE = 'oldResultsType' | 72 KEY__EDITS__OLD_RESULTS_TYPE = 'oldResultsType' |
72 | 73 |
73 DEFAULT_ACTUALS_DIR = results_mod.DEFAULT_ACTUALS_DIR | 74 DEFAULT_ACTUALS_DIR = compare_to_expectations.DEFAULT_ACTUALS_DIR |
74 DEFAULT_ACTUALS_REPO_REVISION = 'HEAD' | 75 DEFAULT_ACTUALS_REPO_REVISION = 'HEAD' |
75 DEFAULT_ACTUALS_REPO_URL = 'http://skia-autogen.googlecode.com/svn/gm-actual' | 76 DEFAULT_ACTUALS_REPO_URL = 'http://skia-autogen.googlecode.com/svn/gm-actual' |
76 DEFAULT_PORT = 8888 | 77 DEFAULT_PORT = 8888 |
77 | 78 |
78 # Directory within which the server will serve out static files. | 79 # Directory within which the server will serve out static files. |
79 STATIC_CONTENTS_DIR = os.path.realpath(os.path.join(PARENT_DIRECTORY, 'static')) | 80 STATIC_CONTENTS_DIR = os.path.realpath(os.path.join(PARENT_DIRECTORY, 'static')) |
80 GENERATED_IMAGES_DIR = os.path.join(STATIC_CONTENTS_DIR, 'generated-images') | 81 GENERATED_IMAGES_DIR = os.path.join(STATIC_CONTENTS_DIR, 'generated-images') |
81 GENERATED_JSON_DIR = os.path.join(STATIC_CONTENTS_DIR, 'generated-json') | 82 GENERATED_JSON_DIR = os.path.join(STATIC_CONTENTS_DIR, 'generated-json') |
82 | 83 |
83 # How often (in seconds) clients should reload while waiting for initial | 84 # How often (in seconds) clients should reload while waiting for initial |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 # Because the Skia repo is moving from SVN to git, and git does not | 256 # Because the Skia repo is moving from SVN to git, and git does not |
256 # support updating a single directory tree, we have to update the entire | 257 # support updating a single directory tree, we have to update the entire |
257 # repo checkout. | 258 # repo checkout. |
258 # | 259 # |
259 # Because Skia uses depot_tools, we have to update using "gclient sync" | 260 # Because Skia uses depot_tools, we have to update using "gclient sync" |
260 # instead of raw git (or SVN) update. Happily, this will work whether | 261 # instead of raw git (or SVN) update. Happily, this will work whether |
261 # the checkout was created using git or SVN. | 262 # the checkout was created using git or SVN. |
262 if self._reload_seconds: | 263 if self._reload_seconds: |
263 logging.info( | 264 logging.info( |
264 'Updating expected GM results in %s by syncing Skia repo ...' % | 265 'Updating expected GM results in %s by syncing Skia repo ...' % |
265 results_mod.DEFAULT_EXPECTATIONS_DIR) | 266 compare_to_expectations.DEFAULT_EXPECTATIONS_DIR) |
266 _run_command(['gclient', 'sync'], TRUNK_DIRECTORY) | 267 _run_command(['gclient', 'sync'], TRUNK_DIRECTORY) |
267 | 268 |
268 new_results = results_mod.Results( | 269 new_results = compare_to_expectations.Results( |
269 actuals_root=self._actuals_dir, | 270 actuals_root=self._actuals_dir, |
270 generated_images_root=GENERATED_IMAGES_DIR, | 271 generated_images_root=GENERATED_IMAGES_DIR, |
271 diff_base_url=os.path.relpath( | 272 diff_base_url=os.path.relpath( |
272 GENERATED_IMAGES_DIR, GENERATED_JSON_DIR)) | 273 GENERATED_IMAGES_DIR, GENERATED_JSON_DIR)) |
273 | 274 |
274 if not os.path.isdir(GENERATED_JSON_DIR): | 275 if not os.path.isdir(GENERATED_JSON_DIR): |
275 os.makedirs(GENERATED_JSON_DIR) | 276 os.makedirs(GENERATED_JSON_DIR) |
276 for summary_type in SUMMARY_TYPES: | 277 for summary_type in SUMMARY_TYPES: |
277 gm_json.WriteToFile( | 278 gm_json.WriteToFile( |
278 new_results.get_packaged_results_of_type(results_type=summary_type), | 279 new_results.get_packaged_results_of_type(results_type=summary_type), |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 | 397 |
397 { | 398 { |
398 KEY__EDITS__OLD_RESULTS_TYPE: 'all', # type of results that the client | 399 KEY__EDITS__OLD_RESULTS_TYPE: 'all', # type of results that the client |
399 # loaded and then made | 400 # loaded and then made |
400 # modifications to | 401 # modifications to |
401 KEY__EDITS__OLD_RESULTS_HASH: 39850913, # hash of results when the client | 402 KEY__EDITS__OLD_RESULTS_HASH: 39850913, # hash of results when the client |
402 # loaded them (ensures that the | 403 # loaded them (ensures that the |
403 # client and server apply | 404 # client and server apply |
404 # modifications to the same base) | 405 # modifications to the same base) |
405 KEY__EDITS__MODIFICATIONS: [ | 406 KEY__EDITS__MODIFICATIONS: [ |
406 # as needed by results_mod.edit_expectations() | 407 # as needed by compare_to_expectations.edit_expectations() |
407 ... | 408 ... |
408 ], | 409 ], |
409 } | 410 } |
410 | 411 |
411 Raises an Exception if there were any problems. | 412 Raises an Exception if there were any problems. |
412 """ | 413 """ |
413 if not _SERVER.is_editable: | 414 if not _SERVER.is_editable: |
414 raise Exception('this server is not running in --editable mode') | 415 raise Exception('this server is not running in --editable mode') |
415 | 416 |
416 content_type = self.headers[_HTTP_HEADER_CONTENT_TYPE] | 417 content_type = self.headers[_HTTP_HEADER_CONTENT_TYPE] |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 _SERVER = Server(actuals_dir=args.actuals_dir, | 527 _SERVER = Server(actuals_dir=args.actuals_dir, |
527 actuals_repo_revision=args.actuals_revision, | 528 actuals_repo_revision=args.actuals_revision, |
528 actuals_repo_url=args.actuals_repo, | 529 actuals_repo_url=args.actuals_repo, |
529 port=args.port, export=args.export, editable=args.editable, | 530 port=args.port, export=args.export, editable=args.editable, |
530 reload_seconds=args.reload) | 531 reload_seconds=args.reload) |
531 _SERVER.run() | 532 _SERVER.run() |
532 | 533 |
533 | 534 |
534 if __name__ == '__main__': | 535 if __name__ == '__main__': |
535 main() | 536 main() |
OLD | NEW |