| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2008-2010 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2008-2010 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 """Generate index.html files for a Google Storage for Developers directory. | 6 """Generate index.html files for a Google Storage for Developers directory. |
| 7 | 7 |
| 8 Google Storage for Developers provides only a raw set of objects. | 8 Google Storage for Developers provides only a raw set of objects. |
| 9 For some buckets we would like to be able to support browsing of the directory | 9 For some buckets we would like to be able to support browsing of the directory |
| 10 tree. This utility will generate the needed index and upload/update it. | 10 tree. This utility will generate the needed index and upload/update it. |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 if not index_list: | 147 if not index_list: |
| 148 mutex.release() | 148 mutex.release() |
| 149 return | 149 return |
| 150 d = index_list.pop(0) | 150 d = index_list.pop(0) |
| 151 mutex.release() | 151 mutex.release() |
| 152 # Find just this directories children. | 152 # Find just this directories children. |
| 153 children = [o for o in objects if posixpath.dirname(o) == d] | 153 children = [o for o in objects if posixpath.dirname(o) == d] |
| 154 # Generate it. | 154 # Generate it. |
| 155 try: | 155 try: |
| 156 GenerateIndex(d, children, directories, options) | 156 GenerateIndex(d, children, directories, options) |
| 157 except Exception, e: | 157 except Exception, e: # pylint: disable=W0703 |
| 158 mutex.acquire() | 158 mutex.acquire() |
| 159 errors.append(e) | 159 errors.append(e) |
| 160 print str(e) | 160 print str(e) |
| 161 mutex.release() | 161 mutex.release() |
| 162 | 162 |
| 163 | 163 |
| 164 def GenerateIndexes(path, options): | 164 def GenerateIndexes(path, options): |
| 165 """Generate all relevant indexes for a given gsd path.""" | 165 """Generate all relevant indexes for a given gsd path.""" |
| 166 # Get a list of objects under this prefix. | 166 # Get a list of objects under this prefix. |
| 167 cmd = [options.gsutil, 'ls', posixpath.join(path, '*')] | 167 cmd = [options.gsutil, 'ls', posixpath.join(path, '*')] |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 dest='gsutil', help='path to gsutil') | 210 dest='gsutil', help='path to gsutil') |
| 211 options, args = parser.parse_args(argv) | 211 options, args = parser.parse_args(argv) |
| 212 if len(args) != 2 or not args[1].startswith('gs://'): | 212 if len(args) != 2 or not args[1].startswith('gs://'): |
| 213 parser.print_help() | 213 parser.print_help() |
| 214 return 1 | 214 return 1 |
| 215 return GenerateIndexes(args[1], options) | 215 return GenerateIndexes(args[1], options) |
| 216 | 216 |
| 217 | 217 |
| 218 if __name__ == '__main__': | 218 if __name__ == '__main__': |
| 219 sys.exit(main(sys.argv)) | 219 sys.exit(main(sys.argv)) |
| OLD | NEW |