OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import logging | 5 import logging |
6 import os | 6 import os |
7 import traceback | 7 import traceback |
8 | 8 |
9 from chroot_file_system import ChrootFileSystem | 9 from chroot_file_system import ChrootFileSystem |
10 from content_provider import ContentProvider | 10 from content_provider import ContentProvider |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 default_extensions = config.get('defaultExtensions', ()) | 116 default_extensions = config.get('defaultExtensions', ()) |
117 supports_templates = config.get('supportsTemplates', False) | 117 supports_templates = config.get('supportsTemplates', False) |
118 supports_zip = config.get('supportsZip', False) | 118 supports_zip = config.get('supportsZip', False) |
119 | 119 |
120 if 'chromium' in config: | 120 if 'chromium' in config: |
121 chromium_config = config['chromium'] | 121 chromium_config = config['chromium'] |
122 if 'dir' not in chromium_config: | 122 if 'dir' not in chromium_config: |
123 logging.error('%s: "chromium" must have a "dir" property' % name) | 123 logging.error('%s: "chromium" must have a "dir" property' % name) |
124 return None | 124 return None |
125 file_system = ChrootFileSystem(self._host_file_system, | 125 file_system = ChrootFileSystem(self._host_file_system, |
| 126 |
| 127 chromium_config['dir']) |
| 128 # TODO(rockot): Remove this in a future patch. It should not be needed once |
| 129 # the new content_providers.json is committed. |
| 130 elif 'gitiles' in config: |
| 131 chromium_config = config['gitiles'] |
| 132 if 'dir' not in chromium_config: |
| 133 logging.error('%s: "chromium" must have a "dir" property' % name) |
| 134 return None |
| 135 file_system = ChrootFileSystem(self._host_file_system, |
126 chromium_config['dir']) | 136 chromium_config['dir']) |
127 elif 'gitiles' in config: | |
128 gitiles_config = config['gitiles'] | |
129 if 'dir' not in gitiles_config: | |
130 logging.error('%s: "gitiles" must have a "dir" property' % name) | |
131 return None | |
132 file_system = ChrootFileSystem(GitilesFileSystem.Create(), | |
133 gitiles_config['dir']) | |
134 elif 'gcs' in config: | 137 elif 'gcs' in config: |
135 gcs_config = config['gcs'] | 138 gcs_config = config['gcs'] |
136 if 'bucket' not in gcs_config: | 139 if 'bucket' not in gcs_config: |
137 logging.error('%s: "gcs" must have a "bucket" property' % name) | 140 logging.error('%s: "gcs" must have a "bucket" property' % name) |
138 return None | 141 return None |
139 bucket = gcs_config['bucket'] | 142 bucket = gcs_config['bucket'] |
140 if not bucket.startswith('gs://'): | 143 if not bucket.startswith('gs://'): |
141 logging.error('%s: bucket %s should start with gs://' % (name, bucket)) | 144 logging.error('%s: bucket %s should start with gs://' % (name, bucket)) |
142 return None | 145 return None |
143 bucket = bucket[len('gs://'):] | 146 bucket = bucket[len('gs://'):] |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 logging.error('Error %s Cron for ContentProvider "%s":\n%s' % | 183 logging.error('Error %s Cron for ContentProvider "%s":\n%s' % |
181 (action, name, traceback.format_exc())) | 184 (action, name, traceback.format_exc())) |
182 return None | 185 return None |
183 | 186 |
184 futures = [(name, safe(name, | 187 futures = [(name, safe(name, |
185 'initializing', | 188 'initializing', |
186 self._CreateContentProvider(name, config).Cron)) | 189 self._CreateContentProvider(name, config).Cron)) |
187 for name, config in self._GetConfig().iteritems()] | 190 for name, config in self._GetConfig().iteritems()] |
188 return Future(callback= | 191 return Future(callback= |
189 lambda: [safe(name, 'resolving', f.Get) for name, f in futures if f]) | 192 lambda: [safe(name, 'resolving', f.Get) for name, f in futures if f]) |
OLD | NEW |