OLD | NEW |
1 # This file is part of the Adblock Plus web scripts, | 1 # This file is part of the Adblock Plus web scripts, |
2 # Copyright (C) 2006-2016 Eyeo GmbH | 2 # Copyright (C) 2006-2016 Eyeo GmbH |
3 # | 3 # |
4 # Adblock Plus is free software: you can redistribute it and/or modify | 4 # Adblock Plus is free software: you can redistribute it and/or modify |
5 # it under the terms of the GNU General Public License version 3 as | 5 # it under the terms of the GNU General Public License version 3 as |
6 # published by the Free Software Foundation. | 6 # published by the Free Software Foundation. |
7 # | 7 # |
8 # Adblock Plus is distributed in the hope that it will be useful, | 8 # Adblock Plus is distributed in the hope that it will be useful, |
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 | 176 |
177 if self.nightlyConfig and not self.nightlyConfig.has_section(self.reposi
toryName): | 177 if self.nightlyConfig and not self.nightlyConfig.has_section(self.reposi
toryName): |
178 self.nightlyConfig.add_section(self.repositoryName) | 178 self.nightlyConfig.add_section(self.repositoryName) |
179 | 179 |
180 def __str__(self): | 180 def __str__(self): |
181 """ | 181 """ |
182 Provides a string representation of this configuration | 182 Provides a string representation of this configuration |
183 """ | 183 """ |
184 return self.repositoryName | 184 return self.repositoryName |
185 | 185 |
186 def readMetadata(self, version='tip'): | 186 def readMetadata(self, version): |
187 genericFilename = 'metadata' | 187 genericFilename = 'metadata' |
188 filename = '%s.%s' % (genericFilename, self.type) | 188 filename = '%s.%s' % (genericFilename, self.type) |
189 files = subprocess.check_output(['hg', '-R', self.repository, | 189 files = subprocess.check_output(['hg', '-R', self.repository, |
190 'locate', '-r', version]).splitlines() | 190 'locate', '-r', version]).splitlines() |
191 | 191 |
192 if filename not in files: | 192 if filename not in files: |
193 # some repositories like those for Android and | 193 # some repositories like those for Android and |
194 # Internet Explorer don't have metadata files | 194 # Internet Explorer don't have metadata files |
195 if genericFilename not in files: | 195 if genericFilename not in files: |
196 return None | 196 return None |
197 | 197 |
198 # Fall back to platform-independent metadata file | 198 # Fall back to platform-independent metadata file |
199 filename = genericFilename | 199 filename = genericFilename |
200 | 200 |
201 command = ['hg', '-R', self.repository, 'cat', '-r', version, os.path.jo
in(self.repository, filename)] | 201 command = ['hg', '-R', self.repository, 'cat', '-r', version, os.path.jo
in(self.repository, filename)] |
202 result = subprocess.check_output(command) | 202 result = subprocess.check_output(command) |
203 | 203 |
204 parser = SafeConfigParser() | 204 parser = SafeConfigParser() |
205 parser.readfp(StringIO(result)) | 205 parser.readfp(StringIO(result)) |
206 | 206 |
207 return parser | 207 return parser |
208 | 208 |
209 def getDownloads(self): | 209 def getDownloads(self): |
210 metadata = self.readMetadata() | 210 metadata = self.readMetadata(self.revision) |
211 if metadata: | 211 if metadata: |
212 prefix = metadata.get('general', 'basename') | 212 prefix = metadata.get('general', 'basename') |
213 else: | 213 else: |
214 prefix = os.path.basename(os.path.normpath(self.repository)) | 214 prefix = os.path.basename(os.path.normpath(self.repository)) |
215 prefix += '-' | 215 prefix += '-' |
216 | 216 |
217 command = ['hg', 'locate', '-R', self.downloadsRepo, '-r', 'default'] | 217 command = ['hg', 'locate', '-R', self.downloadsRepo, '-r', 'default'] |
218 for filename in subprocess.check_output(command).splitlines(): | 218 for filename in subprocess.check_output(command).splitlines(): |
219 if filename.startswith(prefix) and filename.endswith(self.packageSuf
fix): | 219 if filename.startswith(prefix) and filename.endswith(self.packageSuf
fix): |
220 yield (filename, filename[len(prefix):len(filename) - len(self.p
ackageSuffix)]) | 220 yield (filename, filename[len(prefix):len(filename) - len(self.p
ackageSuffix)]) |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 | 309 |
310 | 310 |
311 def getDownloadLinks(result): | 311 def getDownloadLinks(result): |
312 """ | 312 """ |
313 gets the download links for all extensions and puts them into the config | 313 gets the download links for all extensions and puts them into the config |
314 object | 314 object |
315 """ | 315 """ |
316 for repo in Configuration.getRepositoryConfigurations(): | 316 for repo in Configuration.getRepositoryConfigurations(): |
317 try: | 317 try: |
318 (downloadURL, version) = _getDownloadLink(repo) | 318 (downloadURL, version) = _getDownloadLink(repo) |
| 319 if downloadURL is None: |
| 320 raise Exception('No download link found for repo: ' + repo) |
319 except: | 321 except: |
320 traceback.print_exc() | 322 traceback.print_exc() |
321 continue | 323 continue |
322 if not result.has_section(repo.repositoryName): | 324 if not result.has_section(repo.repositoryName): |
323 result.add_section(repo.repositoryName) | 325 result.add_section(repo.repositoryName) |
324 result.set(repo.repositoryName, 'downloadURL', downloadURL) | 326 result.set(repo.repositoryName, 'downloadURL', downloadURL) |
325 result.set(repo.repositoryName, 'version', version) | 327 result.set(repo.repositoryName, 'version', version) |
326 | 328 |
327 qrcode = _getQRCode(downloadURL) | 329 qrcode = _getQRCode(downloadURL) |
328 if qrcode is not None: | 330 if qrcode is not None: |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 if not extensions: | 377 if not extensions: |
376 return | 378 return |
377 | 379 |
378 updates = {} | 380 updates = {} |
379 for extension in extensions: | 381 for extension in extensions: |
380 updates[extension['basename']] = { | 382 updates[extension['basename']] = { |
381 'url': extension['updateURL'], | 383 'url': extension['updateURL'], |
382 'version': extension['version'] | 384 'version': extension['version'] |
383 } | 385 } |
384 writeLibabpUpdateManifest(path, updates) | 386 writeLibabpUpdateManifest(path, updates) |
OLD | NEW |