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

Side by Side Diff: utils.py

Issue 29330389: Issue 2956 - Ensure the correct version of jsshell is present (Closed)
Patch Set: Created Nov. 18, 2015, 2:56 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 os 7 import os
8 import platform 8 import platform
9 from StringIO import StringIO 9 from StringIO import StringIO
10 import shutil
11 import subprocess
10 import sys 12 import sys
11 import urllib 13 import urllib
12 import zipfile 14 import zipfile
13 15
14 def ensureJSShell(): 16 def ensureJSShell():
15 baseDir = os.path.dirname(__file__) 17 baseDir = os.path.dirname(__file__)
16 shell_dir = os.path.join(baseDir, 'mozilla') 18 shell_dir = os.path.join(baseDir, 'mozilla')
19
17 if not os.path.exists(shell_dir): 20 if not os.path.exists(shell_dir):
18 os.makedirs(shell_dir) 21 os.makedirs(shell_dir)
19 if sys.platform == 'win32': 22 if sys.platform == 'win32':
20 path = os.path.join(shell_dir, 'js.exe') 23 path = os.path.join(shell_dir, 'js.exe')
21 else: 24 else:
22 path = os.path.join(shell_dir, 'js') 25 path = os.path.join(shell_dir, 'js')
26
23 if os.path.exists(path): 27 if os.path.exists(path):
24 return path 28 # Return the path if jsshell is present and its version is correct
29 try:
30 version = [s for s in subprocess.check_output([path, "--help"]).split("\n" )
Sebastian Noack 2015/11/18 19:53:37 This can be simplified: m = re.search(r"^Versio
kzar 2015/11/19 10:56:41 Done.
31 if s.startswith("Version")][0].split()[1]
32 except (IndexError, subprocess.CalledProcessError):
33 pass
34 else:
35 if version == "JavaScript-C31.5.0esrpre":
sergei 2015/11/18 15:30:06 Nit: I don't know the convention for buildtools bu
sergei 2015/11/18 15:30:06 Nit: In addition it seems better to show some warn
kzar 2015/11/18 15:40:49 Well I would have separated the version string fro
sergei 2015/11/18 15:50:18 I have missed it, in this case it's totally fine f
36 return path
37 # Otherwise remove the old / faulty version, we'll re-download
38 shutil.rmtree(shell_dir)
39 os.makedirs(shell_dir)
25 40
26 supported_platforms = { 41 supported_platforms = {
27 'win32': 'win32', 42 'win32': 'win32',
28 'linux2': { 43 'linux2': {
29 'i686': 'linux-i686', 44 'i686': 'linux-i686',
30 'x86_64': 'linux-x86_64' 45 'x86_64': 'linux-x86_64'
31 }, 46 },
32 'darwin': 'mac', 47 'darwin': 'mac',
33 } 48 }
34 try: 49 try:
(...skipping 13 matching lines...) Expand all
48 63
49 if not os.path.exists(path): 64 if not os.path.exists(path):
50 raise Exception('Downloaded package didn\'t contain JS shell executable') 65 raise Exception('Downloaded package didn\'t contain JS shell executable')
51 66
52 try: 67 try:
53 os.chmod(path, 0700) 68 os.chmod(path, 0700)
54 except: 69 except:
55 pass 70 pass
56 71
57 return path 72 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