Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: utils.py

Issue 29321352: Issue 2744 - Install correct version of JS shell for 64bit Linux (Closed)
Patch Set: Created July 2, 2015, 4:57 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 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.
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 supported_platforms = {
23 'win32': 'win32', 23 'win32': 'win32',
24 'linux2': 'linux-i686', 24 'linux2': {
25 '32bit': 'linux-i686',
26 '64bit': 'linux-x86_64'
27 },
25 'darwin': 'mac', 28 'darwin': 'mac',
26 } 29 }
27 if sys.platform not in platform_map: 30 try:
28 raise Exception('Unknown platform, is there a JS shell version for it?') 31 build = supported_platforms[sys.platform]
32 if isinstance(build, dict):
33 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.
34 except KeyError:
35 raise Exception('Platform %s (%s) not supported by JS shell' % (
36 sys.platform, platform.architecture()[0]
37 ))
29 38
30 download_url = 'https://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/2015/0 2/2015-02-25-00-22-19-mozilla-esr31/jsshell-%s.zip' % platform_map[sys.platform] 39 download_url = 'https://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/2015/0 2/2015-02-25-00-22-19-mozilla-esr31/jsshell-%s.zip' % build
31 data = StringIO(urllib.urlopen(download_url).read()) 40 data = StringIO(urllib.urlopen(download_url).read())
32 zip = zipfile.ZipFile(data) 41 zip = zipfile.ZipFile(data)
33 zip.extractall(shell_dir) 42 zip.extractall(shell_dir)
34 zip.close() 43 zip.close()
35 44
36 if not os.path.exists(path): 45 if not os.path.exists(path):
37 raise Exception('Downloaded package didn\'t contain JS shell executable') 46 raise Exception('Downloaded package didn\'t contain JS shell executable')
38 47
39 try: 48 try:
40 os.chmod(path, 0700) 49 os.chmod(path, 0700)
41 except: 50 except:
42 pass 51 pass
43 52
44 return path 53 return path
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld