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

Side by Side Diff: sitescripts/extensions/bin/updateDownloadLinks.py

Issue 10669003: Link to remote downloads server rather than a local downloads directory (Closed)
Patch Set: Created May 22, 2013, 2:33 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « .sitescripts.example ('k') | sitescripts/extensions/utils.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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-2013 Eyeo GmbH 4 # Copyright (C) 2006-2013 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 if match: 95 if match:
96 return (url, match.group(1)) 96 return (url, match.group(1))
97 else: 97 else:
98 return (None, None) 98 return (None, None)
99 99
100 def getLocalLink(repo): 100 def getLocalLink(repo):
101 """ 101 """
102 gets the link for the newest download of an add-on in the local downloads 102 gets the link for the newest download of an add-on in the local downloads
103 repository 103 repository
104 """ 104 """
105 dir = repo.downloadsDirectory
106 url = repo.downloadsURL 105 url = repo.downloadsURL
107 106
108 highestURL = None 107 highestURL = None
109 highestVersion = None 108 highestVersion = None
110 prefix = os.path.basename(repo.repository) + '-' 109 prefix = os.path.basename(repo.repository) + '-'
111 suffix = repo.packageSuffix 110 suffix = repo.packageSuffix
112 111
113 # go through the downloads directory looking for downloads matching this exten sion 112 # go through the downloads repository looking for downloads matching this exte nsion
114 for fileName in os.listdir(dir): 113 command = ['hg', 'locate', '-R', repo.downloadsRepo, '-r', 'default']
114 result, dummy = subprocess.Popen(command, stdout=subprocess.PIPE).communicate( )
115 for fileName in result.splitlines():
115 if fileName.startswith(prefix) and fileName.endswith(suffix): 116 if fileName.startswith(prefix) and fileName.endswith(suffix):
116 version = fileName[len(prefix):len(fileName) - len(suffix)] 117 version = fileName[len(prefix):len(fileName) - len(suffix)]
117 if highestVersion == None or compareVersions(version, highestVersion) > 0: 118 if highestVersion == None or compareVersions(version, highestVersion) > 0:
118 highestURL = urlparse.urljoin(url, fileName) 119 highestURL = urlparse.urljoin(url, fileName)
119 highestVersion = version 120 highestVersion = version
120 return (highestURL, highestVersion) 121 return (highestURL, highestVersion)
121 122
122 def getDownloadLink(repo): 123 def getDownloadLink(repo):
123 """ 124 """
124 gets the download link to the most current version of an extension 125 gets the download link to the most current version of an extension
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 for repoType in extensions.iterkeys(): 231 for repoType in extensions.iterkeys():
231 manifestPath = get_config().get('extensions', '%sUpdateManifestPath' % repoT ype) 232 manifestPath = get_config().get('extensions', '%sUpdateManifestPath' % repoT ype)
232 template = get_template(get_config().get('extensions', '%sUpdateManifest' % repoType)) 233 template = get_template(get_config().get('extensions', '%sUpdateManifest' % repoType))
233 template.stream({'extensions': extensions[repoType]}).dump(manifestPath) 234 template.stream({'extensions': extensions[repoType]}).dump(manifestPath)
234 235
235 def updateLinks(): 236 def updateLinks():
236 """ 237 """
237 writes the current extension download links to a file 238 writes the current extension download links to a file
238 """ 239 """
239 240
240 # Update downloads directory first
241 downloadsRepository = get_config().get('extensions', 'downloadsDirectory')
242 subprocess.Popen(['hg', '-R', downloadsRepository, 'pull', '-u'], stdout=subp rocess.PIPE).communicate()
243
244 # Now get download links and save them to file 241 # Now get download links and save them to file
245 result = SafeConfigParser() 242 result = SafeConfigParser()
246 getDownloadLinks(result) 243 getDownloadLinks(result)
247 file = open(get_config().get('extensions', 'downloadLinksFile'), 'wb') 244 file = open(get_config().get('extensions', 'downloadLinksFile'), 'wb')
248 result.write(file) 245 result.write(file)
249 file.close() 246 file.close()
250 247
251 writeUpdateManifest(result) 248 writeUpdateManifest(result)
252 249
253 if __name__ == "__main__": 250 if __name__ == "__main__":
254 updateLinks() 251 updateLinks()
OLDNEW
« no previous file with comments | « .sitescripts.example ('k') | sitescripts/extensions/utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld