| LEFT | RIGHT |
| 1 # This Source Code is subject to the terms of the Mozilla Public License | 1 # This Source Code is subject to the terms of the Mozilla Public License |
| 2 # version 2.0 (the "License"). You can obtain a copy of the License at | 2 # version 2.0 (the "License"). You can obtain a copy of the License at |
| 3 # http://mozilla.org/MPL/2.0/. | 3 # http://mozilla.org/MPL/2.0/. |
| 4 | |
| 5 from __future__ import print_function | |
| 6 | 4 |
| 7 import os | 5 import os |
| 8 import platform | 6 import platform |
| 9 import io | 7 import io |
| 10 import zipfile | 8 import zipfile |
| 11 import subprocess | 9 import subprocess |
| 12 | 10 |
| 13 try: | 11 try: |
| 14 from urllib.request import urlopen | 12 from urllib.request import urlopen |
| 15 except ImportError: | 13 except ImportError: |
| 16 import urllib | 14 import urllib2 |
| 17 import contextlib | 15 import contextlib |
| 18 | 16 |
| 19 def urlopen(*args, **kwargs): | 17 def urlopen(*args, **kwargs): |
| 20 return contextlib.closing(urllib.urlopen(*args, **kwargs)) | 18 return contextlib.closing(urllib2.urlopen(*args, **kwargs)) |
| 21 | 19 |
| 22 JSSHELL_DIR = 'mozilla-esr31' | 20 JSSHELL_DIR = 'mozilla-esr31' |
| 23 JSSHELL_URL = ('https://ftp.mozilla.org/pub/mozilla.org/firefox/nightly' | 21 JSSHELL_URL = ('https://ftp.mozilla.org/pub/mozilla.org/firefox/nightly' |
| 24 '/2015/02/2015-02-25-00-22-19-{}' | 22 '/2015/02/2015-02-25-00-22-19-{}' |
| 25 '/jsshell-{{}}.zip'.format(JSSHELL_DIR)) | 23 '/jsshell-{{}}.zip'.format(JSSHELL_DIR)) |
| 26 | 24 |
| 27 JSSHELL_SUPPORTED_PLATFORMS = { | 25 JSSHELL_SUPPORTED_PLATFORMS = { |
| 28 'Windows': 'win32', | 26 'Windows': 'win32', |
| 29 'Linux': { | 27 'Linux': { |
| 30 'i686': 'linux-i686', | 28 'i686': 'linux-i686', |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 def rewrite_js(args, script=None): | 79 def rewrite_js(args, script=None): |
| 82 jsshell = ensure_jsshell() | 80 jsshell = ensure_jsshell() |
| 83 env = {'LD_LIBRARY_PATH': os.path.relpath(os.path.dirname(jsshell))} | 81 env = {'LD_LIBRARY_PATH': os.path.relpath(os.path.dirname(jsshell))} |
| 84 base_dir = os.path.dirname(__file__) | 82 base_dir = os.path.dirname(__file__) |
| 85 | 83 |
| 86 if not script: | 84 if not script: |
| 87 script = os.path.join(base_dir, 'scripts', 'abprewrite.js') | 85 script = os.path.join(base_dir, 'scripts', 'abprewrite.js') |
| 88 | 86 |
| 89 command = [jsshell, os.path.join(base_dir, 'jshydra.js'), script] + args | 87 command = [jsshell, os.path.join(base_dir, 'jshydra.js'), script] + args |
| 90 return subprocess.check_output(command, env=env, universal_newlines=True) | 88 return subprocess.check_output(command, env=env, universal_newlines=True) |
| LEFT | RIGHT |