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

Unified Diff: sitescripts/subscriptions/bin/updateMalwareDomainsList.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/bin/updateMalwareDomainsList.py
===================================================================
--- a/sitescripts/subscriptions/bin/updateMalwareDomainsList.py
+++ b/sitescripts/subscriptions/bin/updateMalwareDomainsList.py
@@ -20,18 +20,18 @@ from StringIO import StringIO
from sitescripts.utils import get_config, setupStderr
if __name__ == '__main__':
setupStderr()
repository = get_config().get('subscriptionDownloads', 'malwaredomains_repository')
tempdir = tempfile.mkdtemp(prefix='malwaredomains')
try:
- subprocess.Popen(['hg', '-q', 'clone', '-U', repository, tempdir]).communicate()
- subprocess.Popen(['hg', '-q', 'up', '-R', tempdir, '-r', 'default']).communicate()
+ subprocess.check_call(['hg', '-q', 'clone', '-U', repository, tempdir])
+ subprocess.check_call(['hg', '-q', 'up', '-R', tempdir, '-r', 'default'])
path = os.path.join(tempdir, 'malwaredomains_full.txt')
file = codecs.open(path, 'wb', encoding='utf-8')
print >>file, '''[Adblock Plus 1.1]
! This is a list of malware domains generated from malwaredomains.com data.
! Homepage: http://malwaredomains.com/?page_id=2
! Last modified: %timestamp%
@@ -42,12 +42,14 @@ if __name__ == '__main__':
zip = zipfile.ZipFile(StringIO(data), 'r')
info = zip.infolist()[0]
for line in str(zip.read(info.filename)).splitlines():
if not line:
continue
print >>file, '||%s^' % line.strip().decode('iso-8859-1')
file.close();
- subprocess.Popen(['hg', '-q', 'commit', '-R', tempdir, '-A', '-u', 'hgbot', '-m', 'Updated malwaredomains.com data']).communicate()
- subprocess.Popen(['hg', '-q', 'push', '-R', tempdir]).communicate()
+ subprocess.check_call(['hg', '-q', 'commit', '-R', tempdir, '-A', '-u', 'hgbot', '-m', 'Updated malwaredomains.com data'])
+
+ # Don't check the result of this call, it will be 1 if nothing needs pushing
+ subprocess.call(['hg', '-q', 'push', '-R', tempdir])
finally:
shutil.rmtree(tempdir, ignore_errors=True)

Powered by Google App Engine
This is Rietveld