rebaseline_server: when first started, tell client results are still being generated
authorcommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 20 Mar 2014 18:31:00 +0000 (18:31 +0000)
committercommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 20 Mar 2014 18:31:00 +0000 (18:31 +0000)
(SkipBuildbotRuns)
NOTREECHECKS=True
NOTRY=True
R=senorblanco@google.com, senorblanco@chromium.org

Author: epoger@google.com

Review URL: https://codereview.chromium.org/206723002

git-svn-id: http://skia.googlecode.com/svn/trunk@13879 2bbb7eff-a529-9590-31e7-b0007b416f81

gm/rebaseline_server/server.py

index 1ca5757..d88d399 100755 (executable)
@@ -87,6 +87,11 @@ RELOAD_INTERVAL_UNTIL_READY = 10
 _HTTP_HEADER_CONTENT_LENGTH = 'Content-Length'
 _HTTP_HEADER_CONTENT_TYPE = 'Content-Type'
 
+SUMMARY_TYPES = [
+    results_mod.KEY__HEADER__RESULTS_ALL,
+    results_mod.KEY__HEADER__RESULTS_FAILURES,
+]
+
 _SERVER = None   # This gets filled in by main()
 
 
@@ -172,6 +177,25 @@ class Server(object):
     self._actuals_repo = _create_svn_checkout(
         dir_path=actuals_dir, repo_url=actuals_repo_url)
 
+    # Since we don't have any results ready yet, prepare a dummy results file
+    # telling any clients that we're still working on the results.
+    response_dict = {
+        results_mod.KEY__HEADER: {
+            results_mod.KEY__HEADER__SCHEMA_VERSION: (
+                results_mod.REBASELINE_SERVER_SCHEMA_VERSION_NUMBER),
+            results_mod.KEY__HEADER__IS_STILL_LOADING: True,
+            results_mod.KEY__HEADER__TIME_UPDATED: 0,
+            results_mod.KEY__HEADER__TIME_NEXT_UPDATE_AVAILABLE: (
+                RELOAD_INTERVAL_UNTIL_READY),
+        },
+    }
+    if not os.path.isdir(GENERATED_JSON_DIR):
+      os.makedirs(GENERATED_JSON_DIR)
+    for summary_type in SUMMARY_TYPES:
+      gm_json.WriteToFile(
+          response_dict,
+          os.path.join(GENERATED_JSON_DIR, '%s.json' % summary_type))
+
     # Reentrant lock that must be held whenever updating EITHER of:
     # 1. self._results
     # 2. the expected or actual results on local disk
@@ -246,10 +270,10 @@ class Server(object):
           generated_images_root=GENERATED_IMAGES_DIR,
           diff_base_url=os.path.relpath(
               GENERATED_IMAGES_DIR, GENERATED_JSON_DIR))
+
       if not os.path.isdir(GENERATED_JSON_DIR):
         os.makedirs(GENERATED_JSON_DIR)
-      for summary_type in [results_mod.KEY__HEADER__RESULTS_ALL,
-                           results_mod.KEY__HEADER__RESULTS_FAILURES]:
+      for summary_type in SUMMARY_TYPES:
         gm_json.WriteToFile(
             new_results.get_packaged_results_of_type(results_type=summary_type),
             os.path.join(GENERATED_JSON_DIR, '%s.json' % summary_type))