| 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 from contextlib import closing | 7 from contextlib import closing |
| 8 import os | 8 import os |
| 9 import platform | 9 import platform |
| 10 from StringIO import StringIO | 10 from StringIO import StringIO |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 shell_dir = os.path.join(baseDir, JSSHELL_DIR + "-" + build) | 41 shell_dir = os.path.join(baseDir, JSSHELL_DIR + "-" + build) |
| 42 if not os.path.exists(shell_dir): | 42 if not os.path.exists(shell_dir): |
| 43 os.makedirs(shell_dir) | 43 os.makedirs(shell_dir) |
| 44 if sys.platform == 'win32': | 44 if sys.platform == 'win32': |
| 45 path = os.path.join(shell_dir, 'js.exe') | 45 path = os.path.join(shell_dir, 'js.exe') |
| 46 else: | 46 else: |
| 47 path = os.path.join(shell_dir, 'js') | 47 path = os.path.join(shell_dir, 'js') |
| 48 | 48 |
| 49 if os.path.exists(path): | 49 if os.path.exists(path): |
| 50 return path | 50 return path |
| 51 |
| 52 with closing(urllib.urlopen(JSSHELL_URL % build)) as response: |
| 53 data = response.read() |
| 51 | 54 |
| 52 with closing(urllib.urlopen(JSSHELL_URL % build)) as response, \ | 55 with zipfile.ZipFile(StringIO(data)) as zip: |
| 53 zipfile.ZipFile(StringIO(response.read())) as zip: | |
| 54 zip.extractall(shell_dir) | 56 zip.extractall(shell_dir) |
| 55 | 57 |
| 56 if not os.path.exists(path): | 58 if not os.path.exists(path): |
| 57 raise Exception('Downloaded package didn\'t contain JS shell executable'
) | 59 raise Exception('Downloaded package didn\'t contain JS shell executable'
) |
| 58 | 60 |
| 59 try: | 61 try: |
| 60 os.chmod(path, 0700) | 62 os.chmod(path, 0700) |
| 61 except: | 63 except: |
| 62 pass | 64 pass |
| 63 | 65 |
| 64 return path | 66 return path |
| OLD | NEW |