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

Side by Side Diff: sitescripts/subscriptions/bin/updateSubscriptionDownloadsCVS.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 # coding: utf-8 1 # coding: utf-8
2 2
3 # This file is part of the Adblock Plus web scripts, 3 # This file is part of the Adblock Plus web scripts,
4 # Copyright (C) 2006-2013 Eyeo GmbH 4 # Copyright (C) 2006-2013 Eyeo GmbH
5 # 5 #
6 # Adblock Plus is free software: you can redistribute it and/or modify 6 # Adblock Plus is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 3 as 7 # it under the terms of the GNU General Public License version 3 as
8 # published by the Free Software Foundation. 8 # published by the Free Software Foundation.
9 # 9 #
10 # Adblock Plus is distributed in the hope that it will be useful, 10 # Adblock Plus is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details. 13 # GNU General Public License for more details.
14 # 14 #
15 # You should have received a copy of the GNU General Public License 15 # You should have received a copy of the GNU General Public License
16 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 16 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
17 17
18 import os, re, subprocess, tempfile, shutil 18 import os, re, subprocess, tempfile, shutil
19 from sitescripts.utils import get_config, setupStderr 19 from sitescripts.utils import get_config, setupStderr
20 20
21 if __name__ == '__main__': 21 if __name__ == '__main__':
22 setupStderr() 22 setupStderr()
23 23
24 source = get_config().get('subscriptionDownloads', 'outdir') 24 source = get_config().get('subscriptionDownloads', 'outdir')
25 cvsroot = get_config().get('subscriptionDownloads', 'cvsroot') 25 cvsroot = get_config().get('subscriptionDownloads', 'cvsroot')
26 cvsdir = get_config().get('subscriptionDownloads', 'cvsdir') 26 cvsdir = get_config().get('subscriptionDownloads', 'cvsdir')
27 dest = tempfile.mkdtemp() 27 dest = tempfile.mkdtemp()
28 try: 28 try:
29 os.chdir(os.path.dirname(dest)) # Yes, CVS sucks 29 os.chdir(os.path.dirname(dest)) # Yes, CVS sucks
30 subprocess.Popen(['cvs', '-Q', '-d', cvsroot, 'checkout', '-d', os.path.base name(dest), cvsdir]).communicate() 30 subprocess.check_call(['cvs', '-Q', '-d', cvsroot, 'checkout', '-d', os.path .basename(dest), cvsdir])
31 os.chdir(dest) 31 os.chdir(dest)
32 (result, dummy) = subprocess.Popen(['rsync', '-a', '--delete', '--out-format =%o %n', '--exclude=CVS', source + '/', dest], stdout=subprocess.PIPE).communica te() 32 result = subprocess.check_output(['rsync', '-a', '--delete', '--out-format=% o %n', '--exclude=CVS', source + '/', dest])
Sebastian Noack 2013/07/04 13:57:51 There is no need to hard-code path separators. Use
33 for line in result.split('\n'): 33 for line in result.split('\n'):
34 match = re.search(r'^(\S+)\s+(.*)', line) 34 match = re.search(r'^(\S+)\s+(.*)', line)
35 if match and match.group(1) == 'send': 35 if match and match.group(1) == 'send':
36 subprocess.Popen(['cvs', '-Q', 'add', match.group(2)]).communicate() 36 subprocess.check_call(['cvs', '-Q', 'add', match.group(2)])
37 elif match and match.group(1) == 'del.': 37 elif match and match.group(1) == 'del.':
38 subprocess.Popen(['cvs', '-Q', 'remove', match.group(2)]).communicate() 38 subprocess.check_call(['cvs', '-Q', 'remove', match.group(2)])
39 subprocess.Popen(['cvs', '-Q', 'commit', '-m', 'Uploading subscription updat es'], stdout=subprocess.PIPE).communicate() 39 subprocess.check_call(['cvs', '-Q', 'commit', '-m', 'Uploading subscription updates'])
40 finally: 40 finally:
41 if os.path.exists(dest): 41 if os.path.exists(dest):
42 shutil.rmtree(dest, True) 42 shutil.rmtree(dest, True)
OLDNEW

Powered by Google App Engine
This is Rietveld