OLD | NEW |
1 # coding: utf-8 | 1 # coding: utf-8 |
2 | 2 |
3 # This Source Code is subject to the terms of the Mozilla Public License | 3 # This Source Code is subject to the terms of the Mozilla Public License |
4 # version 2.0 (the "License"). You can obtain a copy of the License at | 4 # version 2.0 (the "License"). You can obtain a copy of the License at |
5 # http://mozilla.org/MPL/2.0/. | 5 # http://mozilla.org/MPL/2.0/. |
6 | 6 |
7 import sys, os, urllib, zipfile | 7 import sys, os, urllib, zipfile |
8 from StringIO import StringIO | 8 from StringIO import StringIO |
9 | 9 |
10 def ensureJSShell(): | 10 def ensureJSShell(): |
11 baseDir = os.path.dirname(__file__) | 11 baseDir = os.path.dirname(__file__) |
12 shell_dir = os.path.join(baseDir, 'mozilla') | 12 shell_dir = os.path.join(baseDir, 'mozilla') |
13 if not os.path.exists(shell_dir): | 13 if not os.path.exists(shell_dir): |
14 os.makedirs(shell_dir) | 14 os.makedirs(shell_dir) |
15 if sys.platform == 'win32': | 15 if sys.platform == 'win32': |
16 path = os.path.join(shell_dir, 'js.exe') | 16 path = os.path.join(shell_dir, 'js.exe') |
17 else: | 17 else: |
18 path = os.path.join(shell_dir, 'js') | 18 path = os.path.join(shell_dir, 'js') |
19 if os.path.exists(path): | 19 if os.path.exists(path): |
20 return path | 20 return path |
21 | 21 |
22 platform_map = { | 22 platform_map = { |
23 'win32': 'win32', | 23 'win32': 'win32', |
24 'linux2': 'linux-i686', | 24 'linux2': 'linux-i686', |
25 'darwin': 'mac', | 25 'darwin': 'mac', |
26 } | 26 } |
27 if sys.platform not in platform_map: | 27 if sys.platform not in platform_map: |
28 raise Exception('Unknown platform, is there a JS shell version for it?') | 28 raise Exception('Unknown platform, is there a JS shell version for it?') |
29 | 29 |
30 download_url = 'http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/11.0-ca
ndidates/build2/jsshell-%s.zip' % platform_map[sys.platform] | 30 download_url = 'https://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/20.0-c
andidates/build1/jsshell-%s.zip' % platform_map[sys.platform] |
31 data = StringIO(urllib.urlopen(download_url).read()) | 31 data = StringIO(urllib.urlopen(download_url).read()) |
32 zip = zipfile.ZipFile(data) | 32 zip = zipfile.ZipFile(data) |
33 zip.extractall(shell_dir) | 33 zip.extractall(shell_dir) |
34 zip.close() | 34 zip.close() |
35 | 35 |
36 if not os.path.exists(path): | 36 if not os.path.exists(path): |
37 raise Exception('Downloaded package didn\'t contain JS shell executable') | 37 raise Exception('Downloaded package didn\'t contain JS shell executable') |
38 | 38 |
39 try: | 39 try: |
40 os.chmod(path, 0700) | 40 os.chmod(path, 0700) |
41 except: | 41 except: |
42 pass | 42 pass |
43 | 43 |
44 return path | 44 return path |
OLD | NEW |