| Index: utils.py |
| =================================================================== |
| --- a/utils.py |
| +++ b/utils.py |
| @@ -22,16 +22,20 @@ JSSHELL_SUPPORTED_PLATFORMS = { |
| "i686": "linux-i686", |
| "x86_64": "linux-x86_64" |
| }, |
| "darwin": "mac" |
| } |
| def ensureJSShell(): |
| + path = os.environ.get('SPIDERMONKEY_BINARY') |
| + if path and os.path.isfile(path): |
| + return path |
| + |
| baseDir = os.path.dirname(__file__) |
| try: |
| build = JSSHELL_SUPPORTED_PLATFORMS[sys.platform] |
| if isinstance(build, dict): |
| build = build[platform.machine()] |
| except KeyError: |
| raise Exception('Platform %s (%s) not supported by JS shell' % ( |
| @@ -43,17 +47,17 @@ def ensureJSShell(): |
| os.makedirs(shell_dir) |
| if sys.platform == 'win32': |
| path = os.path.join(shell_dir, 'js.exe') |
| else: |
| path = os.path.join(shell_dir, 'js') |
| if os.path.exists(path): |
| return path |
| - |
| + |
| with closing(urllib.urlopen(JSSHELL_URL % build)) as response: |
| data = response.read() |
| with zipfile.ZipFile(StringIO(data)) as zip: |
| zip.extractall(shell_dir) |
| if not os.path.exists(path): |
| raise Exception('Downloaded package didn\'t contain JS shell executable') |