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

Unified Diff: sitescripts/subscriptions/subscriptionParser.py

Issue 10942098: Make sure subprocess calls don`t ignore result codes indicating errors. Fix JS docs generation whil… (Closed)
Patch Set: Fixed wrong argument format Created July 4, 2013, 1:01 p.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/subscriptions/subscriptionParser.py
===================================================================
--- a/sitescripts/subscriptions/subscriptionParser.py
+++ b/sitescripts/subscriptions/subscriptionParser.py
@@ -220,29 +220,24 @@ def calculateSupplemented(lists):
if supplements in lists:
lists[supplements].supplemented.append(fileData)
else:
warn('Subscription %s supplements an unknown subscription %s' % (fileData.name, supplements))
@cached(60)
def get_settings():
repo = os.path.abspath(get_config().get('subscriptions', 'repository'))
- (settingsData, errors) = subprocess.Popen(['hg', '-R', repo, 'cat', '-r', 'default', os.path.join(repo, 'settings')], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
- if errors:
- print >>sys.stderr, errors
-
+ settingsData = subprocess.check_output(['hg', '-q', '-R', repo, 'cat', '-r', 'default', os.path.join(repo, 'settings')])
Sebastian Noack 2013/07/04 13:57:51 The added -q parameter doesn't seem to have any af
settings = SafeConfigParser()
settings.readfp(codecs.getreader('utf8')(StringIO(settingsData)))
return settings
def readSubscriptions():
repo = os.path.abspath(get_config().get('subscriptions', 'repository'))
- (data, errors) = subprocess.Popen(['hg', 'archive', '-R', repo, '-r', 'default', '-t', 'tar', '-I', os.path.join(repo, '*.subscription'), '-'], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
- if errors:
- print >>sys.stderr, errors
+ data = subprocess.check_output(['hg', 'archive', '-q', '-R', repo, '-r', 'default', '-t', 'tar', '-I', os.path.join(repo, '*.subscription'), '-'])
result = {}
tarFile = tarfile.open(mode='r:', fileobj=StringIO(data))
fileInfo = tarFile.next()
while fileInfo:
fileData = parseFile(fileInfo.name, codecs.getreader('utf8')(tarFile.extractfile(fileInfo)))
fileInfo = tarFile.next()
if fileData.unavailable:
@@ -253,21 +248,15 @@ def readSubscriptions():
result[fileData.name] = fileData
tarFile.close()
calculateSupplemented(result)
return result
def getFallbackData():
repo = os.path.abspath(get_config().get('subscriptions', 'repository'))
- (redirectData, errors) = subprocess.Popen(['hg', '-R', repo, 'cat', '-r', 'default', os.path.join(repo, 'redirects')], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
- if errors:
- print >>sys.stderr, errors
-
- (goneData, errors) = subprocess.Popen(['hg', '-R', repo, 'cat', '-r', 'default', os.path.join(repo, 'gone')], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
- if errors:
- print >>sys.stderr, errors
-
+ redirectData = subprocess.check_output(['hg', '-R', repo, 'cat', '-r', 'default', os.path.join(repo, 'redirects')])
+ goneData = subprocess.check_output(['hg', '-R', repo, 'cat', '-r', 'default', os.path.join(repo, 'gone')])
return (redirectData, goneData)
def _validateURL(url):
parseResult = urlparse(url)
return (parseResult.scheme == 'http' or parseResult.scheme == 'https') and parseResult.netloc != ''

Powered by Google App Engine
This is Rietveld