Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 # coding: utf-8 | 1 # coding: utf-8 |
2 | 2 |
3 # This file is part of the Adblock Plus web scripts, | 3 # This file is part of the Adblock Plus web scripts, |
4 # Copyright (C) 2006-2014 Eyeo GmbH | 4 # Copyright (C) 2006-2014 Eyeo GmbH |
5 # | 5 # |
6 # Adblock Plus is free software: you can redistribute it and/or modify | 6 # Adblock Plus is free software: you can redistribute it and/or modify |
7 # it under the terms of the GNU General Public License version 3 as | 7 # it under the terms of the GNU General Public License version 3 as |
8 # published by the Free Software Foundation. | 8 # published by the Free Software Foundation. |
9 # | 9 # |
10 # Adblock Plus is distributed in the hope that it will be useful, | 10 # Adblock Plus is distributed in the hope that it will be useful, |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
170 result.add_section(repo.repositoryName) | 170 result.add_section(repo.repositoryName) |
171 result.set(repo.repositoryName, "downloadURL", downloadURL) | 171 result.set(repo.repositoryName, "downloadURL", downloadURL) |
172 result.set(repo.repositoryName, "version", version) | 172 result.set(repo.repositoryName, "version", version) |
173 | 173 |
174 qrcode = getQRCode(downloadURL) | 174 qrcode = getQRCode(downloadURL) |
175 if qrcode != None: | 175 if qrcode != None: |
176 result.set(repo.repositoryName, "qrcode", qrcode) | 176 result.set(repo.repositoryName, "qrcode", qrcode) |
177 | 177 |
178 def readRawMetadata(repo, version='tip'): | 178 def readRawMetadata(repo, version='tip'): |
179 files = subprocess.check_output(['hg', '-R', repo.repository, 'locate', '-r', version]).splitlines() | 179 files = subprocess.check_output(['hg', '-R', repo.repository, 'locate', '-r', version]).splitlines() |
180 if 'metadata.%s' % repo.type in files: | 180 genericFilename = 'metadata' |
181 command = ['hg', '-R', repo.repository, 'cat', '-r', version, os.path.join(r epo.repository, 'metadata.%s' % repo.type)] | 181 filename = '%s.%s' % (genericFilename, repo.type) |
182 result = subprocess.check_output(command) | 182 |
183 else: | 183 # Fall back to platform-independent metadata file |
184 # Fall back to platform-independent metadata file for now | 184 if filename not in files: |
185 command = ['hg', '-R', repo.repository, 'cat', '-r', version, os.path.join(r epo.repository, 'metadata')] | 185 filename = genericFilename |
186 result = subprocess.check_output(command) | 186 |
Wladimir Palant
2014/04/30 11:50:57
Nit: You only copied that code but |result = subpr
Sebastian Noack
2014/04/30 12:21:45
Even better, just generating the manifest filename
| |
187 command = ['hg', '-R', repo.repository, 'cat', '-r', version, os.path.join(rep o.repository, filename)] | |
188 result = subprocess.check_output(command) | |
187 | 189 |
188 parser = SafeConfigParser() | 190 parser = SafeConfigParser() |
189 parser.readfp(StringIO(result)) | 191 parser.readfp(StringIO(result)) |
190 | 192 |
191 return parser | 193 return parser |
192 | 194 |
193 def readMetadata(repo, version): | 195 def readMetadata(repo, version): |
194 """ | 196 """ |
195 reads extension ID and compatibility information from metadata file in the | 197 reads extension ID and compatibility information from metadata file in the |
196 extension's repository | 198 extension's repository |
(...skipping 13 matching lines...) Expand all Loading... | |
210 'minSdkVersion': usesSdk.attributes["android:minSdkVersion"].value, | 212 'minSdkVersion': usesSdk.attributes["android:minSdkVersion"].value, |
211 } | 213 } |
212 elif repo.type == 'safari': | 214 elif repo.type == 'safari': |
213 metadata = readRawMetadata(repo, version) | 215 metadata = readRawMetadata(repo, version) |
214 return { | 216 return { |
215 'certificateID': getSafariCertificateID(repo.keyFile), | 217 'certificateID': getSafariCertificateID(repo.keyFile), |
216 'version': version, | 218 'version': version, |
217 'shortVersion': version, | 219 'shortVersion': version, |
218 'basename': metadata.get('general', 'basename'), | 220 'basename': metadata.get('general', 'basename'), |
219 } | 221 } |
220 else: | 222 elif repo.type == 'gecko': |
Wladimir Palant
2014/04/30 11:50:57
Nit: Please check |repo.type == 'gecko'| explicitl
Sebastian Noack
2014/04/30 12:21:45
Done.
| |
221 metadata = readRawMetadata(repo, version) | 223 metadata = readRawMetadata(repo, version) |
222 result = { | 224 result = { |
223 'extensionID': metadata.get('general', 'id'), | 225 'extensionID': metadata.get('general', 'id'), |
224 'version': version, | 226 'version': version, |
225 'compat': [] | 227 'compat': [] |
226 } | 228 } |
227 for key, value in KNOWN_APPS.iteritems(): | 229 for key, value in KNOWN_APPS.iteritems(): |
228 if metadata.has_option('compat', key): | 230 if metadata.has_option('compat', key): |
229 minVersion, maxVersion = metadata.get('compat', key).split('/') | 231 minVersion, maxVersion = metadata.get('compat', key).split('/') |
230 result['compat'].append({'id': value, 'minVersion': minVersion, 'maxVers ion': maxVersion}) | 232 result['compat'].append({'id': value, 'minVersion': minVersion, 'maxVers ion': maxVersion}) |
231 return result | 233 return result |
234 else: | |
235 raise Exception('unknown repository type %r' % repo.type) | |
232 | 236 |
233 def writeUpdateManifest(links): | 237 def writeUpdateManifest(links): |
234 """ | 238 """ |
235 writes an update manifest for all Gecko extensions and Android apps | 239 writes an update manifest for all Gecko extensions and Android apps |
236 """ | 240 """ |
237 | 241 |
238 extensions = {'gecko': [], 'android': [], 'safari': []} | 242 extensions = {'gecko': [], 'android': [], 'safari': []} |
239 for repo in Configuration.getRepositoryConfigurations(): | 243 for repo in Configuration.getRepositoryConfigurations(): |
240 if repo.type not in extensions or not links.has_section(repo.repositoryName) : | 244 if repo.type not in extensions or not links.has_section(repo.repositoryName) : |
241 continue | 245 continue |
(...skipping 20 matching lines...) Expand all Loading... | |
262 result = SafeConfigParser() | 266 result = SafeConfigParser() |
263 getDownloadLinks(result) | 267 getDownloadLinks(result) |
264 file = open(get_config().get('extensions', 'downloadLinksFile'), 'wb') | 268 file = open(get_config().get('extensions', 'downloadLinksFile'), 'wb') |
265 result.write(file) | 269 result.write(file) |
266 file.close() | 270 file.close() |
267 | 271 |
268 writeUpdateManifest(result) | 272 writeUpdateManifest(result) |
269 | 273 |
270 if __name__ == "__main__": | 274 if __name__ == "__main__": |
271 updateLinks() | 275 updateLinks() |
LEFT | RIGHT |