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

Unified Diff: sitescripts/management/bin/updateExternalFiles.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/management/bin/updateExternalFiles.py
===================================================================
--- a/sitescripts/management/bin/updateExternalFiles.py
+++ b/sitescripts/management/bin/updateExternalFiles.py
@@ -23,36 +23,38 @@ from shutil import rmtree
def updateExternalFiles():
settings = readSettings()
for setting in settings.itervalues():
tempdir = mkdtemp(prefix='external')
try:
repoPath = setting['targetrepository']
targetPath = os.path.dirname(setting['targetfile'])
filename = os.path.basename(setting['targetfile'])
-
- subprocess.Popen(['hg', 'clone', '-q', '-U', repoPath, tempdir], stdout=subprocess.PIPE).communicate()
- subprocess.Popen(['hg', 'up', '-q', '-R', tempdir, '-r', 'default'], stdout=subprocess.PIPE).communicate()
-
+
+ subprocess.check_call(['hg', 'clone', '-q', '-U', repoPath, tempdir])
+ subprocess.check_call(['hg', 'up', '-q', '-R', tempdir, '-r', 'default'])
+
path = os.path.join(tempdir, targetPath)
if not os.path.exists(path):
os.makedirs(path)
-
+
path = os.path.join(path, filename)
exists = os.path.exists(path)
file = codecs.open(path, 'wb', encoding='utf-8')
data = urllib.urlopen(setting['source']).read().decode('utf-8')
file.write(data)
file.close()
message = 'Updated copy of external file %s'
if not exists:
message = 'Added copy of external file %s'
- subprocess.Popen(['hg', 'commit', '-q', '-A', '-R', tempdir, '-u', 'hgbot', '-m', message % filename], stdout=subprocess.PIPE).communicate()
- subprocess.Popen(['hg', 'push', '-q', '-R', tempdir], stdout=subprocess.PIPE).communicate()
+ subprocess.check_call(['hg', 'commit', '-q', '-A', '-R', tempdir, '-u', 'hgbot', '-m', message % filename])
+
+ # Don't check the result of this call, it will be 1 if nothing needs pushing
+ subprocess.call(['hg', 'push', '-q', '-R', tempdir])
finally:
rmtree(tempdir)
def readSettings():
result = {}
for option, value in get_config().items('externalFiles'):
if option.find('_') < 0:
continue

Powered by Google App Engine
This is Rietveld