| 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 | 142 |
| 143 def __init__(self, | 143 def __init__(self, |
| 144 actuals_dir=DEFAULT_ACTUALS_DIR, | 144 actuals_dir=DEFAULT_ACTUALS_DIR, |
| 145 actuals_repo_revision=DEFAULT_ACTUALS_REPO_REVISION, | 145 actuals_repo_revision=DEFAULT_ACTUALS_REPO_REVISION, |
| 146 actuals_repo_url=DEFAULT_ACTUALS_REPO_URL, | 146 actuals_repo_url=DEFAULT_ACTUALS_REPO_URL, |
| 147 port=DEFAULT_PORT, export=False, editable=True, | 147 port=DEFAULT_PORT, export=False, editable=True, |
| 148 reload_seconds=0): | 148 reload_seconds=0): |
| 149 """ | 149 """ |
| 150 Args: | 150 Args: |
| 151 actuals_dir: directory under which we will check out the latest actual | 151 actuals_dir: directory under which we will check out the latest actual |
| 152 GM results | 152 GM results |
| 153 actuals_repo_revision: revision of actual-results.json files to process | 153 actuals_repo_revision: revision of actual-results.json files to process |
| 154 actuals_repo_url: SVN repo to download actual-results.json files from | 154 actuals_repo_url: SVN repo to download actual-results.json files from; |
| 155 if None or '', don't fetch new actual-results files at all, |
| 156 just compare to whatever files are already in actuals_dir |
| 155 port: which TCP port to listen on for HTTP requests | 157 port: which TCP port to listen on for HTTP requests |
| 156 export: whether to allow HTTP clients on other hosts to access this server | 158 export: whether to allow HTTP clients on other hosts to access this server |
| 157 editable: whether HTTP clients are allowed to submit new baselines | 159 editable: whether HTTP clients are allowed to submit new baselines |
| 158 reload_seconds: polling interval with which to check for new results; | 160 reload_seconds: polling interval with which to check for new results; |
| 159 if 0, don't check for new results at all | 161 if 0, don't check for new results at all |
| 160 """ | 162 """ |
| 161 self._actuals_dir = actuals_dir | 163 self._actuals_dir = actuals_dir |
| 162 self._actuals_repo_revision = actuals_repo_revision | 164 self._actuals_repo_revision = actuals_repo_revision |
| 163 self._actuals_repo_url = actuals_repo_url | 165 self._actuals_repo_url = actuals_repo_url |
| 164 self._port = port | 166 self._port = port |
| 165 self._export = export | 167 self._export = export |
| 166 self._editable = editable | 168 self._editable = editable |
| 167 self._reload_seconds = reload_seconds | 169 self._reload_seconds = reload_seconds |
| 168 self._actuals_repo = _create_svn_checkout( | 170 if actuals_repo_url: |
| 169 dir_path=actuals_dir, repo_url=actuals_repo_url) | 171 self._actuals_repo = _create_svn_checkout( |
| 172 dir_path=actuals_dir, repo_url=actuals_repo_url) |
| 170 | 173 |
| 171 # Reentrant lock that must be held whenever updating EITHER of: | 174 # Reentrant lock that must be held whenever updating EITHER of: |
| 172 # 1. self._results | 175 # 1. self._results |
| 173 # 2. the expected or actual results on local disk | 176 # 2. the expected or actual results on local disk |
| 174 self.results_rlock = threading.RLock() | 177 self.results_rlock = threading.RLock() |
| 175 # self._results will be filled in by calls to update_results() | 178 # self._results will be filled in by calls to update_results() |
| 176 self._results = None | 179 self._results = None |
| 177 | 180 |
| 178 @property | 181 @property |
| 179 def results(self): | 182 def results(self): |
| (...skipping 27 matching lines...) Expand all Loading... |
| 207 the same time. | 210 the same time. |
| 208 | 211 |
| 209 Args: | 212 Args: |
| 210 invalidate: if True, invalidate self._results immediately upon entry; | 213 invalidate: if True, invalidate self._results immediately upon entry; |
| 211 otherwise, we will let readers see those results until we | 214 otherwise, we will let readers see those results until we |
| 212 replace them | 215 replace them |
| 213 """ | 216 """ |
| 214 with self.results_rlock: | 217 with self.results_rlock: |
| 215 if invalidate: | 218 if invalidate: |
| 216 self._results = None | 219 self._results = None |
| 217 logging.info( | 220 if self._actuals_repo_url: |
| 218 'Updating actual GM results in %s to revision %s from repo %s ...' % ( | 221 logging.info( |
| 219 self._actuals_dir, self._actuals_repo_revision, | 222 'Updating actual GM results in %s to revision %s from repo %s ...' |
| 220 self._actuals_repo_url)) | 223 % ( |
| 221 self._actuals_repo.Update(path='.', revision=self._actuals_repo_revision) | 224 self._actuals_dir, self._actuals_repo_revision, |
| 225 self._actuals_repo_url)) |
| 226 self._actuals_repo.Update( |
| 227 path='.', revision=self._actuals_repo_revision) |
| 222 | 228 |
| 223 # We only update the expectations dir if the server was run with a | 229 # We only update the expectations dir if the server was run with a |
| 224 # nonzero --reload argument; otherwise, we expect the user to maintain | 230 # nonzero --reload argument; otherwise, we expect the user to maintain |
| 225 # her own expectations as she sees fit. | 231 # her own expectations as she sees fit. |
| 226 # | 232 # |
| 227 # Because the Skia repo is moving from SVN to git, and git does not | 233 # Because the Skia repo is moving from SVN to git, and git does not |
| 228 # support updating a single directory tree, we have to update the entire | 234 # support updating a single directory tree, we have to update the entire |
| 229 # repo checkout. | 235 # repo checkout. |
| 230 # | 236 # |
| 231 # Because Skia uses depot_tools, we have to update using "gclient sync" | 237 # Because Skia uses depot_tools, we have to update using "gclient sync" |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 datefmt='%m/%d/%Y %H:%M:%S', | 507 datefmt='%m/%d/%Y %H:%M:%S', |
| 502 level=logging.INFO) | 508 level=logging.INFO) |
| 503 parser = argparse.ArgumentParser() | 509 parser = argparse.ArgumentParser() |
| 504 parser.add_argument('--actuals-dir', | 510 parser.add_argument('--actuals-dir', |
| 505 help=('Directory into which we will check out the latest ' | 511 help=('Directory into which we will check out the latest ' |
| 506 'actual GM results. If this directory does not ' | 512 'actual GM results. If this directory does not ' |
| 507 'exist, it will be created. Defaults to %(default)s'), | 513 'exist, it will be created. Defaults to %(default)s'), |
| 508 default=DEFAULT_ACTUALS_DIR) | 514 default=DEFAULT_ACTUALS_DIR) |
| 509 parser.add_argument('--actuals-repo', | 515 parser.add_argument('--actuals-repo', |
| 510 help=('URL of SVN repo to download actual-results.json ' | 516 help=('URL of SVN repo to download actual-results.json ' |
| 511 'files from. Defaults to %(default)s'), | 517 'files from. Defaults to %(default)s ; if set to ' |
| 518 'empty string, just compare to actual-results ' |
| 519 'already found in ACTUALS_DIR.'), |
| 512 default=DEFAULT_ACTUALS_REPO_URL) | 520 default=DEFAULT_ACTUALS_REPO_URL) |
| 513 parser.add_argument('--actuals-revision', | 521 parser.add_argument('--actuals-revision', |
| 514 help=('revision of actual-results.json files to process. ' | 522 help=('revision of actual-results.json files to process. ' |
| 515 'Defaults to %(default)s . Beware of setting this ' | 523 'Defaults to %(default)s . Beware of setting this ' |
| 516 'argument in conjunction with --editable; you ' | 524 'argument in conjunction with --editable; you ' |
| 517 'probably only want to edit results at HEAD.'), | 525 'probably only want to edit results at HEAD.'), |
| 518 default=DEFAULT_ACTUALS_REPO_REVISION) | 526 default=DEFAULT_ACTUALS_REPO_REVISION) |
| 519 parser.add_argument('--editable', action='store_true', | 527 parser.add_argument('--editable', action='store_true', |
| 520 help=('Allow HTTP clients to submit new baselines.')) | 528 help=('Allow HTTP clients to submit new baselines.')) |
| 521 parser.add_argument('--export', action='store_true', | 529 parser.add_argument('--export', action='store_true', |
| (...skipping 19 matching lines...) Expand all Loading... |
| 541 _SERVER = Server(actuals_dir=args.actuals_dir, | 549 _SERVER = Server(actuals_dir=args.actuals_dir, |
| 542 actuals_repo_revision=args.actuals_revision, | 550 actuals_repo_revision=args.actuals_revision, |
| 543 actuals_repo_url=args.actuals_repo, | 551 actuals_repo_url=args.actuals_repo, |
| 544 port=args.port, export=args.export, editable=args.editable, | 552 port=args.port, export=args.export, editable=args.editable, |
| 545 reload_seconds=args.reload) | 553 reload_seconds=args.reload) |
| 546 _SERVER.run() | 554 _SERVER.run() |
| 547 | 555 |
| 548 | 556 |
| 549 if __name__ == '__main__': | 557 if __name__ == '__main__': |
| 550 main() | 558 main() |
| OLD | NEW |