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 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 def fetch_files(self, cache, files): | 647 def fetch_files(self, cache, files): |
648 """Adds files in this manifest not present in files dictionary. | 648 """Adds files in this manifest not present in files dictionary. |
649 | 649 |
650 Preemptively request files. | 650 Preemptively request files. |
651 | 651 |
652 Note that |files| is modified by this function. | 652 Note that |files| is modified by this function. |
653 """ | 653 """ |
654 assert self.can_fetch | 654 assert self.can_fetch |
655 if not self._manifest_parsed or self.files_fetched: | 655 if not self._manifest_parsed or self.files_fetched: |
656 return | 656 return |
657 logging.info('fetch_files(%s)' % self.obj_hash) | 657 logging.debug('fetch_files(%s)' % self.obj_hash) |
658 for filepath, properties in self.data.get('files', {}).iteritems(): | 658 for filepath, properties in self.data.get('files', {}).iteritems(): |
659 # Root manifest has priority on the files being mapped. In particular, | 659 # Root manifest has priority on the files being mapped. In particular, |
660 # overriden files must not be fetched. | 660 # overriden files must not be fetched. |
661 if filepath not in files: | 661 if filepath not in files: |
662 files[filepath] = properties | 662 files[filepath] = properties |
663 if 'sha-1' in properties: | 663 if 'sha-1' in properties: |
664 # Preemptively request files. | 664 # Preemptively request files. |
665 logging.info('fetching %s' % filepath) | 665 logging.debug('fetching %s' % filepath) |
666 cache.retrieve(Remote.MED, properties['sha-1']) | 666 cache.retrieve(Remote.MED, properties['sha-1']) |
667 self.files_fetched = True | 667 self.files_fetched = True |
668 | 668 |
669 | 669 |
670 class Settings(object): | 670 class Settings(object): |
671 """Results of a completely parsed manifest.""" | 671 """Results of a completely parsed manifest.""" |
672 def __init__(self): | 672 def __init__(self): |
673 self.command = [] | 673 self.command = [] |
674 self.files = {} | 674 self.files = {} |
675 self.read_only = None | 675 self.read_only = None |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 settings.load(cache, manifest_hash) | 771 settings.load(cache, manifest_hash) |
772 | 772 |
773 if not settings.command: | 773 if not settings.command: |
774 print >> sys.stderr, 'No command to run' | 774 print >> sys.stderr, 'No command to run' |
775 return 1 | 775 return 1 |
776 | 776 |
777 with Profiler('GetRest') as _prof: | 777 with Profiler('GetRest') as _prof: |
778 logging.debug('Creating directories') | 778 logging.debug('Creating directories') |
779 # Creates the tree of directories to create. | 779 # Creates the tree of directories to create. |
780 directories = set(os.path.dirname(f) for f in settings.files) | 780 directories = set(os.path.dirname(f) for f in settings.files) |
781 for item in directories: | 781 for item in list(directories): |
782 directories.add(os.path.dirname(item)) | 782 while item: |
| 783 directories.add(item) |
| 784 item = os.path.dirname(item) |
783 for d in sorted(directories): | 785 for d in sorted(directories): |
784 if d: | 786 if d: |
785 os.mkdir(os.path.join(outdir, d)) | 787 os.mkdir(os.path.join(outdir, d)) |
786 | 788 |
787 # Creates the links if necessary. | 789 # Creates the links if necessary. |
788 for filepath, properties in settings.files.iteritems(): | 790 for filepath, properties in settings.files.iteritems(): |
789 if 'link' not in properties: | 791 if 'link' not in properties: |
790 continue | 792 continue |
791 outfile = os.path.join(outdir, filepath) | 793 outfile = os.path.join(outdir, filepath) |
792 os.symlink(properties['link'], outfile) | 794 os.symlink(properties['link'], outfile) |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
901 os.path.abspath(options.cache), | 903 os.path.abspath(options.cache), |
902 options.remote, | 904 options.remote, |
903 policies) | 905 policies) |
904 except (ConfigError, MappingError), e: | 906 except (ConfigError, MappingError), e: |
905 print >> sys.stderr, str(e) | 907 print >> sys.stderr, str(e) |
906 return 1 | 908 return 1 |
907 | 909 |
908 | 910 |
909 if __name__ == '__main__': | 911 if __name__ == '__main__': |
910 sys.exit(main()) | 912 sys.exit(main()) |
OLD | NEW |