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

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

Issue 287473002: rename rebaseline_server JSON constants to be more consistent (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 7 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 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 # HTTPServer, and then it could be available to the handler via 447 # HTTPServer, and then it could be available to the handler via
448 # the handler's .server instance variable. 448 # the handler's .server instance variable.
449 results_obj = _SERVER.results 449 results_obj = _SERVER.results
450 if results_obj: 450 if results_obj:
451 response_dict = results_obj.get_packaged_results_of_type( 451 response_dict = results_obj.get_packaged_results_of_type(
452 results_type=results_type, reload_seconds=_SERVER.reload_seconds, 452 results_type=results_type, reload_seconds=_SERVER.reload_seconds,
453 is_editable=_SERVER.is_editable, is_exported=_SERVER.is_exported) 453 is_editable=_SERVER.is_editable, is_exported=_SERVER.is_exported)
454 else: 454 else:
455 now = int(time.time()) 455 now = int(time.time())
456 response_dict = { 456 response_dict = {
457 results_mod.KEY__HEADER: { 457 imagepairset.KEY__ROOT__HEADER: {
458 results_mod.KEY__HEADER__SCHEMA_VERSION: ( 458 results_mod.KEY__HEADER__SCHEMA_VERSION: (
459 results_mod.REBASELINE_SERVER_SCHEMA_VERSION_NUMBER), 459 results_mod.VALUE__HEADER__SCHEMA_VERSION),
460 results_mod.KEY__HEADER__IS_STILL_LOADING: True, 460 results_mod.KEY__HEADER__IS_STILL_LOADING: True,
461 results_mod.KEY__HEADER__TIME_UPDATED: now, 461 results_mod.KEY__HEADER__TIME_UPDATED: now,
462 results_mod.KEY__HEADER__TIME_NEXT_UPDATE_AVAILABLE: ( 462 results_mod.KEY__HEADER__TIME_NEXT_UPDATE_AVAILABLE: (
463 now + RELOAD_INTERVAL_UNTIL_READY), 463 now + RELOAD_INTERVAL_UNTIL_READY),
464 }, 464 },
465 } 465 }
466 self.send_json_dict(response_dict) 466 self.send_json_dict(response_dict)
467 467
468 def do_GET_static(self, path): 468 def do_GET_static(self, path):
469 """ Handle a GET request for a file under STATIC_CONTENTS_SUBDIR . 469 """ Handle a GET request for a file under STATIC_CONTENTS_SUBDIR .
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 data) 542 data)
543 543
544 # Update the results on disk with the information we received from the 544 # Update the results on disk with the information we received from the
545 # client. 545 # client.
546 # We must hold _SERVER.results_rlock while we do this, to guarantee that 546 # We must hold _SERVER.results_rlock while we do this, to guarantee that
547 # no other thread updates expectations (from the Skia repo) while we are 547 # no other thread updates expectations (from the Skia repo) while we are
548 # updating them (using the info we received from the client). 548 # updating them (using the info we received from the client).
549 with _SERVER.results_rlock: 549 with _SERVER.results_rlock:
550 oldResultsType = data[KEY__EDITS__OLD_RESULTS_TYPE] 550 oldResultsType = data[KEY__EDITS__OLD_RESULTS_TYPE]
551 oldResults = _SERVER.results.get_results_of_type(oldResultsType) 551 oldResults = _SERVER.results.get_results_of_type(oldResultsType)
552 oldResultsHash = str(hash(repr(oldResults[imagepairset.KEY__IMAGEPAIRS]))) 552 oldResultsHash = str(hash(repr(
553 oldResults[imagepairset.KEY__ROOT__IMAGEPAIRS])))
553 if oldResultsHash != data[KEY__EDITS__OLD_RESULTS_HASH]: 554 if oldResultsHash != data[KEY__EDITS__OLD_RESULTS_HASH]:
554 raise Exception('results of type "%s" changed while the client was ' 555 raise Exception('results of type "%s" changed while the client was '
555 'making modifications. The client should reload the ' 556 'making modifications. The client should reload the '
556 'results and submit the modifications again.' % 557 'results and submit the modifications again.' %
557 oldResultsType) 558 oldResultsType)
558 _SERVER.results.edit_expectations(data[KEY__EDITS__MODIFICATIONS]) 559 _SERVER.results.edit_expectations(data[KEY__EDITS__MODIFICATIONS])
559 560
560 # Read the updated results back from disk. 561 # Read the updated results back from disk.
561 # We can do this in a separate thread; we should return our success message 562 # We can do this in a separate thread; we should return our success message
562 # to the UI as soon as possible. 563 # to the UI as soon as possible.
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 actuals_repo_revision=args.actuals_revision, 673 actuals_repo_revision=args.actuals_revision,
673 actuals_repo_url=args.actuals_repo, 674 actuals_repo_url=args.actuals_repo,
674 port=args.port, export=args.export, editable=args.editable, 675 port=args.port, export=args.export, editable=args.editable,
675 reload_seconds=args.reload, config_pairs=config_pairs, 676 reload_seconds=args.reload, config_pairs=config_pairs,
676 builder_regex_list=args.builders) 677 builder_regex_list=args.builders)
677 _SERVER.run() 678 _SERVER.run()
678 679
679 680
680 if __name__ == '__main__': 681 if __name__ == '__main__':
681 main() 682 main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698