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

Unified 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.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sitescripts/extensions/bin/updateDownloadLinks.py
===================================================================
--- a/sitescripts/extensions/bin/updateDownloadLinks.py
+++ b/sitescripts/extensions/bin/updateDownloadLinks.py
@@ -106,17 +106,17 @@ def getLocalLink(repo):
highestURL = None
highestVersion = None
prefix = os.path.basename(repo.repository) + '-'
suffix = repo.packageSuffix
# go through the downloads repository looking for downloads matching this extension
command = ['hg', 'locate', '-R', repo.downloadsRepo, '-r', 'default']
- result, dummy = subprocess.Popen(command, stdout=subprocess.PIPE).communicate()
+ result = subprocess.check_output(command)
for fileName in result.splitlines():
if fileName.startswith(prefix) and fileName.endswith(suffix):
version = fileName[len(prefix):len(fileName) - len(suffix)]
if highestVersion == None or compareVersions(version, highestVersion) > 0:
highestURL = urlparse.urljoin(url, fileName)
highestVersion = version
return (highestURL, highestVersion)
@@ -172,36 +172,36 @@ def getDownloadLinks(result):
def readMetadata(repo, version):
"""
reads extension ID and compatibility information from metadata file in the
extension's repository
"""
if repo.type == 'android':
command = ['hg', '-R', repo.repository, 'id', '-r', version, '-n']
- (result, dummy) = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
+ result = subprocess.check_output(command)
revision = re.sub(r'\D', '', result)
command = ['hg', '-R', repo.repository, 'cat', '-r', version, os.path.join(repo.repository, 'AndroidManifest.xml')]
- (result, dummy) = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
+ result = subprocess.check_output(command)
manifest = dom.parseString(result)
usesSdk = manifest.getElementsByTagName('uses-sdk')[0]
return {
'revision': revision,
'minSdkVersion': usesSdk.attributes["android:minSdkVersion"].value,
}
else:
- command = ['hg', '-R', repo.repository, 'cat', '-r', version, os.path.join(repo.repository, 'metadata.%s' % repo.type)]
- (result, dummy) = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
-
- # Fall back to platform-independent metadata file for now
- if not result:
+ try:
+ command = ['hg', '-R', repo.repository, 'cat', '-r', version, os.path.join(repo.repository, 'metadata.%s' % repo.type)]
+ result = subprocess.check_output(command)
+ except:
+ # Fall back to platform-independent metadata file for now
command = ['hg', '-R', repo.repository, 'cat', '-r', version, os.path.join(repo.repository, 'metadata')]
- (result, dummy) = subprocess.Popen(command, stdout=subprocess.PIPE).communicate()
+ result = subprocess.check_output(command)
parser = SafeConfigParser()
parser.readfp(StringIO(result))
result = {
'extensionID': parser.get('general', 'id'),
'version': version,
'compat': []

Powered by Google App Engine
This is Rietveld