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

Side by Side 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: Addressed issues Created July 5, 2013, 11:22 a.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,
(...skipping 25 matching lines...) Expand all
36 if not os.path.exists(path): 36 if not os.path.exists(path):
37 os.makedirs(path) 37 os.makedirs(path)
38 38
39 path = os.path.join(path, filename) 39 path = os.path.join(path, filename)
40 exists = os.path.exists(path) 40 exists = os.path.exists(path)
41 file = codecs.open(path, 'wb', encoding='utf-8') 41 file = codecs.open(path, 'wb', encoding='utf-8')
42 data = urllib.urlopen(setting['source']).read().decode('utf-8') 42 data = urllib.urlopen(setting['source']).read().decode('utf-8')
43 file.write(data) 43 file.write(data)
44 file.close() 44 file.close()
45 45
46 message = 'Updated copy of external file %s' 46 if subprocess.check_output(['hg', 'stat', '-R', tempdir]) != '':
47 if not exists: 47 message = 'Updated copy of external file %s'
48 message = 'Added copy of external file %s' 48 if not exists:
49 subprocess.check_call(['hg', 'commit', '-q', '-A', '-R', tempdir, '-u', 'h gbot', '-m', message % filename]) 49 message = 'Added copy of external file %s'
50 50 subprocess.check_call(['hg', 'commit', '-q', '-A', '-R', tempdir, '-u', 'hgbot', '-m', message % filename])
51 # Don't check the result of this call, it will be 1 if nothing needs pushi ng 51 subprocess.call(['hg', 'push', '-q', '-R', tempdir])
52 subprocess.call(['hg', 'push', '-q', '-R', tempdir])
53 finally: 52 finally:
54 rmtree(tempdir) 53 rmtree(tempdir)
55 54
56 def readSettings(): 55 def readSettings():
57 result = {} 56 result = {}
58 for option, value in get_config().items('externalFiles'): 57 for option, value in get_config().items('externalFiles'):
59 if option.find('_') < 0: 58 if option.find('_') < 0:
60 continue 59 continue
61 name, setting = option.rsplit('_', 2) 60 name, setting = option.rsplit('_', 2)
62 if not setting in ('source', 'targetrepository', 'targetfile'): 61 if not setting in ('source', 'targetrepository', 'targetfile'):
63 continue 62 continue
64 63
65 if not name in result: 64 if not name in result:
66 result[name] = { 65 result[name] = {
67 'source': None, 66 'source': None,
68 'targetrepository': None, 67 'targetrepository': None,
69 'targetfile': None 68 'targetfile': None
70 } 69 }
71 result[name][setting] = value 70 result[name][setting] = value
72 return result 71 return result
73 72
74 if __name__ == '__main__': 73 if __name__ == '__main__':
75 setupStderr() 74 setupStderr()
76 updateExternalFiles() 75 updateExternalFiles()
OLDNEW

Powered by Google App Engine
This is Rietveld