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

Unified 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.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils.py
diff --git a/utils.py b/utils.py
index ac3014ae675e7cf67fd33965c7f4f5a2eb13195b..4b11c3cc46b4c520e67b4dcb0e82aca81713c5dd 100644
--- a/utils.py
+++ b/utils.py
@@ -7,6 +7,8 @@
import os
import platform
from StringIO import StringIO
+import shutil
+import subprocess
import sys
import urllib
import zipfile
@@ -14,14 +16,27 @@ import zipfile
def ensureJSShell():
baseDir = os.path.dirname(__file__)
shell_dir = os.path.join(baseDir, 'mozilla')
+
if not os.path.exists(shell_dir):
os.makedirs(shell_dir)
if sys.platform == 'win32':
path = os.path.join(shell_dir, 'js.exe')
else:
path = os.path.join(shell_dir, 'js')
+
if os.path.exists(path):
- return path
+ # Return the path if jsshell is present and its version is correct
+ try:
+ 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.
+ if s.startswith("Version")][0].split()[1]
+ except (IndexError, subprocess.CalledProcessError):
+ pass
+ else:
+ 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
+ return path
+ # Otherwise remove the old / faulty version, we'll re-download
+ shutil.rmtree(shell_dir)
+ os.makedirs(shell_dir)
supported_platforms = {
'win32': 'win32',
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld