LEFT | RIGHT |
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:]) |
LEFT | RIGHT |