Index: utils.py |
diff --git a/utils.py b/utils.py |
index 6fdd8b4f758696c587cace041cedaff5b7b973a1..4f2ec6c01bb0eae9a8f1de127015fe362418a790 100644 |
--- a/utils.py |
+++ b/utils.py |
@@ -4,7 +4,7 @@ |
# version 2.0 (the "License"). You can obtain a copy of the License at |
# http://mozilla.org/MPL/2.0/. |
-import sys, os, urllib, zipfile |
+import os, platform, sys, urllib, zipfile |
Wladimir Palant
2015/07/02 17:48:31
Feel free to convert this to one per line while at
kzar
2015/07/03 13:08:50
Done.
|
from StringIO import StringIO |
def ensureJSShell(): |
@@ -19,15 +19,24 @@ def ensureJSShell(): |
if os.path.exists(path): |
return path |
- platform_map = { |
+ supported_platforms = { |
'win32': 'win32', |
- 'linux2': 'linux-i686', |
+ 'linux2': { |
+ '32bit': 'linux-i686', |
+ '64bit': 'linux-x86_64' |
+ }, |
'darwin': 'mac', |
} |
- if sys.platform not in platform_map: |
- raise Exception('Unknown platform, is there a JS shell version for it?') |
- |
- download_url = 'https://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/2015/02/2015-02-25-00-22-19-mozilla-esr31/jsshell-%s.zip' % platform_map[sys.platform] |
+ try: |
+ build = supported_platforms[sys.platform] |
+ if isinstance(build, dict): |
+ build = build[platform.architecture()[0]] |
Wladimir Palant
2015/07/02 17:48:31
This will give you the architecture of the Python
kzar
2015/07/03 13:08:50
Done.
|
+ except KeyError: |
+ raise Exception('Platform %s (%s) not supported by JS shell' % ( |
+ sys.platform, platform.architecture()[0] |
+ )) |
+ |
+ download_url = 'https://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/2015/02/2015-02-25-00-22-19-mozilla-esr31/jsshell-%s.zip' % build |
data = StringIO(urllib.urlopen(download_url).read()) |
zip = zipfile.ZipFile(data) |
zip.extractall(shell_dir) |