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

Side by Side Diff: sitescripts/subscriptions/combineSubscriptions.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.
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 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # coding: utf-8 2 # coding: utf-8
3 3
4 # This file is part of the Adblock Plus web scripts, 4 # This file is part of the Adblock Plus web scripts,
5 # Copyright (C) 2006-2013 Eyeo GmbH 5 # Copyright (C) 2006-2013 Eyeo GmbH
6 # 6 #
7 # Adblock Plus is free software: you can redistribute it and/or modify 7 # Adblock Plus is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License version 3 as 8 # it under the terms of the GNU General Public License version 3 as
9 # published by the Free Software Foundation. 9 # published by the Free Software Foundation.
10 # 10 #
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 oldData = re.sub(r'\s*\d+ \w+ \d+ \d+:\d+ UTC', '', oldData) 80 oldData = re.sub(r'\s*\d+ \w+ \d+ \d+:\d+ UTC', '', oldData)
81 newData = re.sub(checksumRegExp, '', data) 81 newData = re.sub(checksumRegExp, '', data)
82 newData = re.sub(r'\s*\d+ \w+ \d+ \d+:\d+ UTC', '', newData) 82 newData = re.sub(r'\s*\d+ \w+ \d+ \d+:\d+ UTC', '', newData)
83 if oldData == newData: 83 if oldData == newData:
84 changed = False 84 changed = False
85 if changed: 85 if changed:
86 handle = codecs.open(filePath, 'wb', encoding='utf-8') 86 handle = codecs.open(filePath, 'wb', encoding='utf-8')
87 handle.write(data) 87 handle.write(data)
88 handle.close() 88 handle.close()
89 try: 89 try:
90 subprocess.Popen(['7za', 'a', '-tgzip', '-mx=9', '-bd', '-mpass=15', fileP ath + '.gz', filePath], stdout=subprocess.PIPE).communicate() 90 subprocess.check_output(['7za', 'a', '-tgzip', '-mx=9', '-bd', '-mpass=15' , filePath + '.gz', filePath])
91 except: 91 except:
92 print >>sys.stderr, 'Failed to compress file %s. Please ensure that p7zip is installed on the system.' % filePath 92 print >>sys.stderr, 'Failed to compress file %s. Please ensure that p7zip is installed on the system.' % filePath
93 93
94 def processVerbatimFile(sourceDir, targetDir, file): 94 def processVerbatimFile(sourceDir, targetDir, file):
95 handle = codecs.open(os.path.join(sourceDir, file), 'rb', encoding='utf-8') 95 handle = codecs.open(os.path.join(sourceDir, file), 'rb', encoding='utf-8')
96 conditionalWrite(os.path.join(targetDir, file), handle.read()) 96 conditionalWrite(os.path.join(targetDir, file), handle.read())
97 handle.close() 97 handle.close()
98 98
99 def processSubscriptionFile(sourceName, sourceDirs, targetDir, file, timeout): 99 def processSubscriptionFile(sourceName, sourceDirs, targetDir, file, timeout):
100 sourceDir = sourceDirs[sourceName] 100 sourceDir = sourceDirs[sourceName]
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 timeout = 30 322 timeout = 30
323 for option, value in opts: 323 for option, value in opts:
324 if option in ('-h', '--help'): 324 if option in ('-h', '--help'):
325 usage() 325 usage()
326 sys.exit() 326 sys.exit()
327 elif option in ('-t', '--timeout'): 327 elif option in ('-t', '--timeout'):
328 timeout = int(value) 328 timeout = int(value)
329 329
330 if os.path.exists(os.path.join(sourceDir, '.hg')): 330 if os.path.exists(os.path.join(sourceDir, '.hg')):
331 # Our source is a Mercurial repository, try updating 331 # Our source is a Mercurial repository, try updating
332 subprocess.Popen(['hg', '-R', sourceDir, 'pull', '--update']).communicate() 332 subprocess.check_call(['hg', '-q', '-R', sourceDir, 'pull', '--update'])
333 333
334 combineSubscriptions(sourceDir, targetDir, timeout) 334 combineSubscriptions(sourceDir, targetDir, timeout)
OLDNEW

Powered by Google App Engine
This is Rietveld