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 json | 5 import json |
6 import logging | 6 import logging |
7 import operator | 7 import operator |
8 | 8 |
9 from appengine_url_fetcher import AppEngineUrlFetcher | 9 from appengine_url_fetcher import AppEngineUrlFetcher |
10 import url_constants | 10 import url_constants |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
130 ''' | 130 ''' |
131 if version == 'trunk': | 131 if version == 'trunk': |
132 return 'trunk' | 132 return 'trunk' |
133 | 133 |
134 branch = self._branch_object_store.Get(version).Get() | 134 branch = self._branch_object_store.Get(version).Get() |
135 if branch is not None: | 135 if branch is not None: |
136 return branch | 136 return branch |
137 | 137 |
138 version_json = json.loads(self._history_result.Get().content) | 138 version_json = json.loads(self._history_result.Get().content) |
139 for entry in version_json['events']: | 139 for entry in version_json['events']: |
140 # Here, entry['title'] looks like: 'title - version#.#.branch#.#' | 140 # Here, entry['title'] looks like: '<title> - <version>.##.<branch>.##' |
141 version_title = entry['title'].split(' - ')[1].split('.') | 141 version_title = entry['title'].split(' - ')[1].split('.') |
142 if version_title[0] == str(version): | 142 if version_title[0] == str(version): |
143 self._branch_object_store.Set(str(version), version_title[2]) | 143 self._branch_object_store.Set(str(version), version_title[2]) |
144 return int(version_title[2]) | 144 return int(version_title[2]) |
145 | 145 |
146 raise ValueError( | 146 raise ValueError('The branch for %s could not be found.' % version) |
147 'The branch for %s could not be found.' % version) | 147 |
148 def GetChannelForVersion(self, version): | |
149 '''Returns the name of the development channel corresponding to a given | |
150 version number. | |
151 ''' | |
152 for channel_info in self.GetAllChannelInfo(): | |
153 if channel_info.channel == 'stable' and version <= channel_info.version: | |
154 return channel_info.channel | |
155 elif version == channel_info.version: | |
156 return channel_info.channel | |
epeterson
2013/06/21 00:48:26
Here's the new GetChannelForVersion method, create
not at google - send to devlin
2013/06/21 00:54:11
cool. no else after returns though. just if .. if.
epeterson
2013/06/22 01:42:40
Done.
| |
148 | 157 |
149 def GetLatestVersionNumber(self): | 158 def GetLatestVersionNumber(self): |
150 '''Returns the most recent version number found using data stored on | 159 '''Returns the most recent version number found using data stored on |
151 omahaproxy. | 160 omahaproxy. |
152 ''' | 161 ''' |
153 latest_version = self._version_object_store.Get('latest').Get() | 162 latest_version = self._version_object_store.Get('latest').Get() |
154 if latest_version is not None: | 163 if latest_version is not None: |
155 return latest_version | 164 return latest_version |
156 | 165 |
157 version_json = json.loads(self._history_result.Get().content) | 166 version_json = json.loads(self._history_result.Get().content) |
158 latest_version = 0 | 167 latest_version = 0 |
159 for entry in version_json['events']: | 168 for entry in version_json['events']: |
160 version_title = entry['title'].split(' - ')[1].split('.') | 169 version_title = entry['title'].split(' - ')[1].split('.') |
161 version = int(version_title[0]) | 170 version = int(version_title[0]) |
162 if version > latest_version: | 171 if version > latest_version: |
163 latest_version = version | 172 latest_version = version |
164 | 173 |
165 self._version_object_store.Set('latest', latest_version) | 174 self._version_object_store.Set('latest', latest_version) |
166 return latest_version | 175 return latest_version |
OLD | NEW |