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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
80 GENERATED_IMAGES_DIR = os.path.join(STATIC_CONTENTS_DIR, 'generated-images') | 80 GENERATED_IMAGES_DIR = os.path.join(STATIC_CONTENTS_DIR, 'generated-images') |
81 GENERATED_JSON_DIR = os.path.join(STATIC_CONTENTS_DIR, 'generated-json') | 81 GENERATED_JSON_DIR = os.path.join(STATIC_CONTENTS_DIR, 'generated-json') |
82 | 82 |
83 # How often (in seconds) clients should reload while waiting for initial | 83 # How often (in seconds) clients should reload while waiting for initial |
84 # results to load. | 84 # results to load. |
85 RELOAD_INTERVAL_UNTIL_READY = 10 | 85 RELOAD_INTERVAL_UNTIL_READY = 10 |
86 | 86 |
87 _HTTP_HEADER_CONTENT_LENGTH = 'Content-Length' | 87 _HTTP_HEADER_CONTENT_LENGTH = 'Content-Length' |
88 _HTTP_HEADER_CONTENT_TYPE = 'Content-Type' | 88 _HTTP_HEADER_CONTENT_TYPE = 'Content-Type' |
89 | 89 |
90 SUMMARY_TYPES = [ | |
91 results_mod.KEY__HEADER__RESULTS_ALL, | |
92 results_mod.KEY__HEADER__RESULTS_FAILURES, | |
93 ] | |
94 | |
90 _SERVER = None # This gets filled in by main() | 95 _SERVER = None # This gets filled in by main() |
91 | 96 |
92 | 97 |
93 def _run_command(args, directory): | 98 def _run_command(args, directory): |
94 """Runs a command and returns stdout as a single string. | 99 """Runs a command and returns stdout as a single string. |
95 | 100 |
96 Args: | 101 Args: |
97 args: the command to run, as a list of arguments | 102 args: the command to run, as a list of arguments |
98 directory: directory within which to run the command | 103 directory: directory within which to run the command |
99 | 104 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
165 self._actuals_dir = actuals_dir | 170 self._actuals_dir = actuals_dir |
166 self._actuals_repo_revision = actuals_repo_revision | 171 self._actuals_repo_revision = actuals_repo_revision |
167 self._actuals_repo_url = actuals_repo_url | 172 self._actuals_repo_url = actuals_repo_url |
168 self._port = port | 173 self._port = port |
169 self._export = export | 174 self._export = export |
170 self._editable = editable | 175 self._editable = editable |
171 self._reload_seconds = reload_seconds | 176 self._reload_seconds = reload_seconds |
172 self._actuals_repo = _create_svn_checkout( | 177 self._actuals_repo = _create_svn_checkout( |
173 dir_path=actuals_dir, repo_url=actuals_repo_url) | 178 dir_path=actuals_dir, repo_url=actuals_repo_url) |
174 | 179 |
180 # Since we don't have any results ready yet, prepare a dummy results file | |
epoger
2014/03/20 18:26:44
Reason for the change:
Since https://code.google.
| |
181 # telling any clients that we're still working on the results. | |
182 response_dict = { | |
183 results_mod.KEY__HEADER: { | |
184 results_mod.KEY__HEADER__SCHEMA_VERSION: ( | |
185 results_mod.REBASELINE_SERVER_SCHEMA_VERSION_NUMBER), | |
186 results_mod.KEY__HEADER__IS_STILL_LOADING: True, | |
187 results_mod.KEY__HEADER__TIME_UPDATED: 0, | |
188 results_mod.KEY__HEADER__TIME_NEXT_UPDATE_AVAILABLE: ( | |
189 RELOAD_INTERVAL_UNTIL_READY), | |
190 }, | |
191 } | |
192 if not os.path.isdir(GENERATED_JSON_DIR): | |
193 os.makedirs(GENERATED_JSON_DIR) | |
194 for summary_type in SUMMARY_TYPES: | |
195 gm_json.WriteToFile( | |
196 response_dict, | |
197 os.path.join(GENERATED_JSON_DIR, '%s.json' % summary_type)) | |
198 | |
175 # Reentrant lock that must be held whenever updating EITHER of: | 199 # Reentrant lock that must be held whenever updating EITHER of: |
176 # 1. self._results | 200 # 1. self._results |
177 # 2. the expected or actual results on local disk | 201 # 2. the expected or actual results on local disk |
178 self.results_rlock = threading.RLock() | 202 self.results_rlock = threading.RLock() |
179 # self._results will be filled in by calls to update_results() | 203 # self._results will be filled in by calls to update_results() |
180 self._results = None | 204 self._results = None |
181 | 205 |
182 @property | 206 @property |
183 def results(self): | 207 def results(self): |
184 """ Returns the most recently generated results, or None if we don't have | 208 """ Returns the most recently generated results, or None if we don't have |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
239 logging.info( | 263 logging.info( |
240 'Updating expected GM results in %s by syncing Skia repo ...' % | 264 'Updating expected GM results in %s by syncing Skia repo ...' % |
241 results_mod.DEFAULT_EXPECTATIONS_DIR) | 265 results_mod.DEFAULT_EXPECTATIONS_DIR) |
242 _run_command(['gclient', 'sync'], TRUNK_DIRECTORY) | 266 _run_command(['gclient', 'sync'], TRUNK_DIRECTORY) |
243 | 267 |
244 new_results = results_mod.Results( | 268 new_results = results_mod.Results( |
245 actuals_root=self._actuals_dir, | 269 actuals_root=self._actuals_dir, |
246 generated_images_root=GENERATED_IMAGES_DIR, | 270 generated_images_root=GENERATED_IMAGES_DIR, |
247 diff_base_url=os.path.relpath( | 271 diff_base_url=os.path.relpath( |
248 GENERATED_IMAGES_DIR, GENERATED_JSON_DIR)) | 272 GENERATED_IMAGES_DIR, GENERATED_JSON_DIR)) |
273 | |
249 if not os.path.isdir(GENERATED_JSON_DIR): | 274 if not os.path.isdir(GENERATED_JSON_DIR): |
250 os.makedirs(GENERATED_JSON_DIR) | 275 os.makedirs(GENERATED_JSON_DIR) |
251 for summary_type in [results_mod.KEY__HEADER__RESULTS_ALL, | 276 for summary_type in SUMMARY_TYPES: |
252 results_mod.KEY__HEADER__RESULTS_FAILURES]: | |
253 gm_json.WriteToFile( | 277 gm_json.WriteToFile( |
254 new_results.get_packaged_results_of_type(results_type=summary_type), | 278 new_results.get_packaged_results_of_type(results_type=summary_type), |
255 os.path.join(GENERATED_JSON_DIR, '%s.json' % summary_type)) | 279 os.path.join(GENERATED_JSON_DIR, '%s.json' % summary_type)) |
256 | 280 |
257 self._results = new_results | 281 self._results = new_results |
258 | 282 |
259 def _result_loader(self, reload_seconds=0): | 283 def _result_loader(self, reload_seconds=0): |
260 """ Call self.update_results(), either once or periodically. | 284 """ Call self.update_results(), either once or periodically. |
261 | 285 |
262 Params: | 286 Params: |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
502 _SERVER = Server(actuals_dir=args.actuals_dir, | 526 _SERVER = Server(actuals_dir=args.actuals_dir, |
503 actuals_repo_revision=args.actuals_revision, | 527 actuals_repo_revision=args.actuals_revision, |
504 actuals_repo_url=args.actuals_repo, | 528 actuals_repo_url=args.actuals_repo, |
505 port=args.port, export=args.export, editable=args.editable, | 529 port=args.port, export=args.export, editable=args.editable, |
506 reload_seconds=args.reload) | 530 reload_seconds=args.reload) |
507 _SERVER.run() | 531 _SERVER.run() |
508 | 532 |
509 | 533 |
510 if __name__ == '__main__': | 534 if __name__ == '__main__': |
511 main() | 535 main() |
OLD | NEW |