OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Reads a manifest, creates a tree of hardlinks and runs the test. | 6 """Reads a manifest, creates a tree of hardlinks and runs the test. |
7 | 7 |
8 Keeps a local cache. | 8 Keeps a local cache. |
9 """ | 9 """ |
10 | 10 |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
210 """Retrieves a file from the remote and add it to the cache.""" | 210 """Retrieves a file from the remote and add it to the cache.""" |
211 assert not '/' in item | 211 assert not '/' in item |
212 try: | 212 try: |
213 index = self.state.index(item) | 213 index = self.state.index(item) |
214 # Was already in cache. Update it's LRU value. | 214 # Was already in cache. Update it's LRU value. |
215 self.state.pop(index) | 215 self.state.pop(index) |
216 self.state.append(item) | 216 self.state.append(item) |
217 return False | 217 return False |
218 except ValueError: | 218 except ValueError: |
219 out = self.path(item) | 219 out = self.path(item) |
220 download_or_copy(os.path.join(self.remote, item), out) | 220 download_or_copy(self.remote.rstrip('/') + '/' + item, out) |
M-A Ruel
2012/05/18 17:42:29
technically, you could have used posixpath but it'
| |
221 if os.path.exists(out): | 221 if os.path.exists(out): |
222 self.state.append(item) | 222 self.state.append(item) |
223 else: | 223 else: |
224 logging.error('File, %s, not placed in cache' % item) | 224 logging.error('File, %s, not placed in cache' % item) |
225 return True | 225 return True |
226 finally: | 226 finally: |
227 self.save() | 227 self.save() |
228 | 228 |
229 def path(self, item): | 229 def path(self, item): |
230 """Returns the path to one item.""" | 230 """Returns the path to one item.""" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
315 parser.error('Unsupported args %s' % ' '.join(args)) | 315 parser.error('Unsupported args %s' % ' '.join(args)) |
316 | 316 |
317 manifest = json.load(open_remote(options.manifest)) | 317 manifest = json.load(open_remote(options.manifest)) |
318 return run_tha_test( | 318 return run_tha_test( |
319 manifest, os.path.abspath(options.cache), options.remote, | 319 manifest, os.path.abspath(options.cache), options.remote, |
320 options.max_cache_size, options.min_free_space) | 320 options.max_cache_size, options.min_free_space) |
321 | 321 |
322 | 322 |
323 if __name__ == '__main__': | 323 if __name__ == '__main__': |
324 sys.exit(main()) | 324 sys.exit(main()) |
OLD | NEW |