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

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

Issue 10942098: Make sure subprocess calls don`t ignore result codes indicating errors. Fix JS docs generation whil… (Closed)
Patch Set: Created July 4, 2013, 11:23 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 """ 104 """
105 url = repo.downloadsURL 105 url = repo.downloadsURL
106 106
107 highestURL = None 107 highestURL = None
108 highestVersion = None 108 highestVersion = None
109 prefix = os.path.basename(repo.repository) + '-' 109 prefix = os.path.basename(repo.repository) + '-'
110 suffix = repo.packageSuffix 110 suffix = repo.packageSuffix
111 111
112 # go through the downloads repository looking for downloads matching this exte nsion 112 # go through the downloads repository looking for downloads matching this exte nsion
113 command = ['hg', 'locate', '-R', repo.downloadsRepo, '-r', 'default'] 113 command = ['hg', 'locate', '-R', repo.downloadsRepo, '-r', 'default']
114 result, dummy = subprocess.Popen(command, stdout=subprocess.PIPE).communicate( ) 114 result = subprocess.check_output(command)
115 for fileName in result.splitlines(): 115 for fileName in result.splitlines():
116 if fileName.startswith(prefix) and fileName.endswith(suffix): 116 if fileName.startswith(prefix) and fileName.endswith(suffix):
117 version = fileName[len(prefix):len(fileName) - len(suffix)] 117 version = fileName[len(prefix):len(fileName) - len(suffix)]
118 if highestVersion == None or compareVersions(version, highestVersion) > 0: 118 if highestVersion == None or compareVersions(version, highestVersion) > 0:
119 highestURL = urlparse.urljoin(url, fileName) 119 highestURL = urlparse.urljoin(url, fileName)
120 highestVersion = version 120 highestVersion = version
121 return (highestURL, highestVersion) 121 return (highestURL, highestVersion)
122 122
123 def getDownloadLink(repo): 123 def getDownloadLink(repo):
124 """ 124 """
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 if qrcode != None: 170 if qrcode != None:
171 result.set(repo.repositoryName, "qrcode", qrcode) 171 result.set(repo.repositoryName, "qrcode", qrcode)
172 172
173 def readMetadata(repo, version): 173 def readMetadata(repo, version):
174 """ 174 """
175 reads extension ID and compatibility information from metadata file in the 175 reads extension ID and compatibility information from metadata file in the
176 extension's repository 176 extension's repository
177 """ 177 """
178 if repo.type == 'android': 178 if repo.type == 'android':
179 command = ['hg', '-R', repo.repository, 'id', '-r', version, '-n'] 179 command = ['hg', '-R', repo.repository, 'id', '-r', version, '-n']
180 (result, dummy) = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=s ubprocess.PIPE).communicate() 180 result = subprocess.check_output(command)
181 revision = re.sub(r'\D', '', result) 181 revision = re.sub(r'\D', '', result)
182 182
183 command = ['hg', '-R', repo.repository, 'cat', '-r', version, os.path.join(r epo.repository, 'AndroidManifest.xml')] 183 command = ['hg', '-R', repo.repository, 'cat', '-r', version, os.path.join(r epo.repository, 'AndroidManifest.xml')]
184 (result, dummy) = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=s ubprocess.PIPE).communicate() 184 result = subprocess.check_output(command)
185 manifest = dom.parseString(result) 185 manifest = dom.parseString(result)
186 usesSdk = manifest.getElementsByTagName('uses-sdk')[0] 186 usesSdk = manifest.getElementsByTagName('uses-sdk')[0]
187 187
188 return { 188 return {
189 'revision': revision, 189 'revision': revision,
190 'minSdkVersion': usesSdk.attributes["android:minSdkVersion"].value, 190 'minSdkVersion': usesSdk.attributes["android:minSdkVersion"].value,
191 } 191 }
192 else: 192 else:
193 command = ['hg', '-R', repo.repository, 'cat', '-r', version, os.path.join(r epo.repository, 'metadata.%s' % repo.type)] 193 try:
194 (result, dummy) = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=s ubprocess.PIPE).communicate() 194 command = ['hg', '-R', repo.repository, 'cat', '-r', version, os.path.join (repo.repository, 'metadata.%s' % repo.type)]
195 195 result = subprocess.check_output(command)
196 # Fall back to platform-independent metadata file for now 196 except:
197 if not result: 197 # Fall back to platform-independent metadata file for now
198 command = ['hg', '-R', repo.repository, 'cat', '-r', version, os.path.join (repo.repository, 'metadata')] 198 command = ['hg', '-R', repo.repository, 'cat', '-r', version, os.path.join (repo.repository, 'metadata')]
199 (result, dummy) = subprocess.Popen(command, stdout=subprocess.PIPE).commun icate() 199 result = subprocess.check_output(command)
200 200
201 parser = SafeConfigParser() 201 parser = SafeConfigParser()
202 parser.readfp(StringIO(result)) 202 parser.readfp(StringIO(result))
203 203
204 result = { 204 result = {
205 'extensionID': parser.get('general', 'id'), 205 'extensionID': parser.get('general', 'id'),
206 'version': version, 206 'version': version,
207 'compat': [] 207 'compat': []
208 } 208 }
209 for key, value in KNOWN_APPS.iteritems(): 209 for key, value in KNOWN_APPS.iteritems():
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 result = SafeConfigParser() 242 result = SafeConfigParser()
243 getDownloadLinks(result) 243 getDownloadLinks(result)
244 file = open(get_config().get('extensions', 'downloadLinksFile'), 'wb') 244 file = open(get_config().get('extensions', 'downloadLinksFile'), 'wb')
245 result.write(file) 245 result.write(file)
246 file.close() 246 file.close()
247 247
248 writeUpdateManifest(result) 248 writeUpdateManifest(result)
249 249
250 if __name__ == "__main__": 250 if __name__ == "__main__":
251 updateLinks() 251 updateLinks()
OLDNEW

Powered by Google App Engine
This is Rietveld