OLD | NEW |
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, 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, '-U', 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 result, dummy = subprocess.Popen(command, stdout=subprocess.PIPE, env=env).com
municate() |
24 result = result.replace('\r', '') | 24 result = result.replace('\r', '') |
25 return result | 25 return result |
26 | 26 |
27 if __name__ == '__main__': | 27 if __name__ == '__main__': |
28 try: | 28 try: |
29 scriptArgsStart = sys.argv.index('--arg') | 29 scriptArgsStart = sys.argv.index('--arg') |
30 except ValueError: | 30 except ValueError: |
31 scriptArgsStart = len(sys.argv) | 31 scriptArgsStart = len(sys.argv) |
32 print doRewrite(sys.argv[1:scriptArgsStart], sys.argv[scriptArgsStart + 1:]) | 32 print doRewrite(sys.argv[1:scriptArgsStart], sys.argv[scriptArgsStart + 1:]) |
OLD | NEW |