Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: sitescripts/extensions/bin/updateDownloadLinks.py

Issue 5723465818570752: Issue 520 - Generate PAD files for download portals when updating download links (Closed)
Left Patch Set: Addressed comments Created May 26, 2014, 12:04 p.m.
Right Patch Set: Addressed comments Created June 4, 2014, 4:35 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « sitescripts/extensions/android.py ('k') | sitescripts/extensions/pad/__init__.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 return (linkTag.firstChild.data, versionTag.firstChild.data) 63 return (linkTag.firstChild.data, versionTag.firstChild.data)
64 else: 64 else:
65 return (None, None) 65 return (None, None)
66 66
67 def getGoogleDownloadLink(galleryID): 67 def getGoogleDownloadLink(galleryID):
68 """ 68 """
69 gets download link for a Chrome add-on from the Chrome Gallery site 69 gets download link for a Chrome add-on from the Chrome Gallery site
70 """ 70 """
71 galleryID = urlencode(galleryID) 71 galleryID = urlencode(galleryID)
72 72
73 url = 'https://clients2.google.com/service/update2/crx?x=' 73 url = 'https://clients2.google.com/service/update2/crx?x=%s' % urlencode('id=% s&uc' % galleryID)
74 url += urlencode('id=%s&uc' % galleryID)
75 document = dom.parse(urlopen(url)) 74 document = dom.parse(urlopen(url))
76 updateTags = document.getElementsByTagName('updatecheck') 75 updateTags = document.getElementsByTagName('updatecheck')
77 version = updateTags and updateTags[0].getAttribute('version') 76 version = updateTags and updateTags[0].getAttribute('version')
78 77
79 if not version: 78 if not version:
80 return (None, None) 79 return (None, None)
81 80
82 request = urllib2.Request('https://chrome.google.com/webstore/detail/_/' + gal leryID) 81 request = urllib2.Request('https://chrome.google.com/webstore/detail/_/' + gal leryID)
83 request.get_method = lambda : 'HEAD' 82 request.get_method = lambda : 'HEAD'
84 url = urllib2.urlopen(request).geturl() 83 url = urllib2.urlopen(request).geturl()
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 if len(extensions['android']) > 1: 225 if len(extensions['android']) > 1:
227 print >>sys.stderr, 'Warning: more than one Android app defined, update mani fest only works for one' 226 print >>sys.stderr, 'Warning: more than one Android app defined, update mani fest only works for one'
228 227
229 for repoType in extensions.iterkeys(): 228 for repoType in extensions.iterkeys():
230 manifestPath = get_config().get('extensions', '%sUpdateManifestPath' % repoT ype) 229 manifestPath = get_config().get('extensions', '%sUpdateManifestPath' % repoT ype)
231 template = get_template(get_config().get('extensions', '%sUpdateManifest' % repoType)) 230 template = get_template(get_config().get('extensions', '%sUpdateManifest' % repoType))
232 template.stream({'extensions': extensions[repoType]}).dump(manifestPath) 231 template.stream({'extensions': extensions[repoType]}).dump(manifestPath)
233 232
234 def writePadFile(links): 233 def writePadFile(links):
235 for repo in Configuration.getRepositoryConfigurations(): 234 for repo in Configuration.getRepositoryConfigurations():
236 if repo.padTemplate and links.has_section(repo.repositoryName): 235 if repo.pad and links.has_section(repo.repositoryName):
237 PadFile.forRepository(repo, links.get(repo.repositoryName, 'version'), 236 PadFile.forRepository(repo, links.get(repo.repositoryName, 'version'),
238 links.get(repo.repositoryName, 'downloadURL')) .write() 237 links.get(repo.repositoryName, 'downloadURL')) .write()
239 238
240 def updateLinks(): 239 def updateLinks():
241 """ 240 """
242 writes the current extension download links to a file 241 writes the current extension download links to a file
243 """ 242 """
244 243
245 # Now get download links and save them to file 244 # Now get download links and save them to file
246 result = SafeConfigParser() 245 result = SafeConfigParser()
247 getDownloadLinks(result) 246 getDownloadLinks(result)
248 file = open(get_config().get('extensions', 'downloadLinksFile'), 'wb') 247 file = open(get_config().get('extensions', 'downloadLinksFile'), 'wb')
249 result.write(file) 248 result.write(file)
250 file.close() 249 file.close()
251 250
252 writeUpdateManifest(result) 251 writeUpdateManifest(result)
253 writePadFile(result) 252 writePadFile(result)
254 253
255 if __name__ == "__main__": 254 if __name__ == "__main__":
256 updateLinks() 255 updateLinks()
LEFTRIGHT

Powered by Google App Engine
This is Rietveld