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

Delta Between Two Patch Sets: abp_rewrite.py

Issue 11039026: Use a subprocess wrapper that will throw if a command returns a non-zero result code (Closed)
Left Patch Set: Created July 4, 2013, 7:18 a.m.
Right Patch Set: Restored stderr redirection in autotest Created July 4, 2013, 7:42 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | autotest.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # coding: utf-8 2 # coding: utf-8
3 3
4 # This Source Code is subject to the terms of the Mozilla Public License 4 # This Source Code is subject to the terms of the Mozilla Public License
5 # version 2.0 (the "License"). You can obtain a copy of the License at 5 # version 2.0 (the "License"). You can obtain a copy of the License at
6 # http://mozilla.org/MPL/2.0/. 6 # http://mozilla.org/MPL/2.0/.
7 7
8 import sys, os, utils 8 import sys, os, subprocess, utils
9 9
10 def doRewrite(files, args): 10 def doRewrite(files, args):
11 application = utils.ensureJSShell() 11 application = utils.ensureJSShell()
12 12
13 env = { 13 env = {
14 'LD_LIBRARY_PATH': os.path.relpath(os.path.dirname(application)), 14 'LD_LIBRARY_PATH': os.path.relpath(os.path.dirname(application)),
15 } 15 }
16 16
17 baseDir = os.path.dirname(utils.__file__) 17 baseDir = os.path.dirname(utils.__file__)
18 command = [ 18 command = [
19 application, os.path.join(baseDir, 'jshydra.js'), 19 application, os.path.join(baseDir, 'jshydra.js'),
20 os.path.join(baseDir, 'scripts', 'abprewrite.js'), 20 os.path.join(baseDir, 'scripts', 'abprewrite.js'),
21 '--arg', ' '.join(args) 21 '--arg', ' '.join(args)
22 ] + files 22 ] + files
23 return utils.run(command, utils.STREAMS_STDOUT, env=env).replace('\r', '') 23 return subprocess.check_output(command, env=env).replace('\r', '')
24 24
25 if __name__ == '__main__': 25 if __name__ == '__main__':
26 try: 26 try:
27 scriptArgsStart = sys.argv.index('--arg') 27 scriptArgsStart = sys.argv.index('--arg')
28 except ValueError: 28 except ValueError:
29 scriptArgsStart = len(sys.argv) 29 scriptArgsStart = len(sys.argv)
30 print doRewrite(sys.argv[1:scriptArgsStart], sys.argv[scriptArgsStart + 1:]) 30 print doRewrite(sys.argv[1:scriptArgsStart], sys.argv[scriptArgsStart + 1:])
LEFTRIGHT
« no previous file | autotest.py » ('j') | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld