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

Side by Side Diff: abp_rewrite.py

Issue 11039026: Use a subprocess wrapper that will throw if a command returns a non-zero result code (Closed)
Patch Set: Created July 4, 2013, 7:18 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
« no previous file with comments | « no previous file | autotest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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, subprocess, utils 8 import sys, os, 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 result, dummy = subprocess.Popen(command, stdout=subprocess.PIPE, env=env).com municate() 23 return utils.run(command, utils.STREAMS_STDOUT, env=env).replace('\r', '')
24 result = result.replace('\r', '')
25 return result
26 24
27 if __name__ == '__main__': 25 if __name__ == '__main__':
28 try: 26 try:
29 scriptArgsStart = sys.argv.index('--arg') 27 scriptArgsStart = sys.argv.index('--arg')
30 except ValueError: 28 except ValueError:
31 scriptArgsStart = len(sys.argv) 29 scriptArgsStart = len(sys.argv)
32 print doRewrite(sys.argv[1:scriptArgsStart], sys.argv[scriptArgsStart + 1:]) 30 print doRewrite(sys.argv[1:scriptArgsStart], sys.argv[scriptArgsStart + 1:])
OLDNEW
« no previous file with comments | « no previous file | autotest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld