| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 |
| 6 |
| 5 from data_source import DataSource | 7 from data_source import DataSource |
| 6 from docs_server_utils import StringIdentity | 8 from docs_server_utils import StringIdentity |
| 7 from environment import IsPreviewServer | 9 from environment import IsPreviewServer |
| 8 from file_system import FileNotFoundError | 10 from file_system import FileNotFoundError |
| 9 from future import Future, All | 11 from future import Future, All |
| 10 from jsc_view import JSCView, GetEventByNameFromEvents | 12 from jsc_view import JSCView, GetEventByNameFromEvents |
| 11 from platform_util import GetPlatforms | 13 from platform_util import GetPlatforms |
| 12 from samples_data_source import CreateSamplesView | 14 from samples_data_source import CreateSamplesView |
| 13 | 15 |
| 14 | 16 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 return Future(callback=resolve) | 84 return Future(callback=resolve) |
| 83 | 85 |
| 84 def get(self, platform): | 86 def get(self, platform): |
| 85 '''Return a getter object so that templates can perform lookups such | 87 '''Return a getter object so that templates can perform lookups such |
| 86 as apis.extensions.runtime. | 88 as apis.extensions.runtime. |
| 87 ''' | 89 ''' |
| 88 getter = lambda: 0 | 90 getter = lambda: 0 |
| 89 getter.get = lambda api_name: self._GetImpl(platform, api_name).Get() | 91 getter.get = lambda api_name: self._GetImpl(platform, api_name).Get() |
| 90 return getter | 92 return getter |
| 91 | 93 |
| 92 def Cron(self): | 94 def GetRefreshPaths(self): |
| 93 futures = [] | 95 tasks = [] |
| 94 for platform in GetPlatforms(): | 96 for platform in GetPlatforms(): |
| 95 futures += [self._GetImpl(platform, name) | 97 tasks += ['%s/%s' % (platform, api) |
| 96 for name in self._platform_bundle.GetAPIModels(platform).GetNames()] | 98 for api in |
| 97 return All(futures, except_pass=FileNotFoundError) | 99 self._platform_bundle.GetAPIModels(platform).GetNames()] |
| 100 return tasks |
| 101 |
| 102 def Refresh(self, path): |
| 103 platform, api = path.split('/') |
| 104 logging.info('Refreshing %s/%s' % (platform, api)) |
| 105 future = self._GetImpl(platform, api) |
| 106 return All([future], except_pass=FileNotFoundError) |
| OLD | NEW |