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: Use regexp to match version number and tidy things up Created Nov. 19, 2015, 10:45 a.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..743ead06185bf5c052de10735facb357783f8796 100644
--- a/utils.py
+++ b/utils.py
@@ -6,22 +6,38 @@
import os
import platform
+import re
from StringIO import StringIO
+import shutil
+import subprocess
import sys
import urllib
import zipfile
+JSSHELL_VERSION = "JavaScript-C31.5.0esrpre"
+JSSHELL_URL = ("https://ftp.mozilla.org/pub/mozilla.org/firefox/nightly"
+ "/2015/02/2015-02-25-00-22-19-mozilla-esr31/jsshell-%s.zip")
+
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
+ match = re.search(r"^Version: (.+)$",
+ subprocess.check_output([path, "--help"]), re.MULTILINE)
+ if match and match.group(1) == JSSHELL_VERSION:
+ return path
+ # Otherwise remove the old / faulty version, we'll re-download
+ shutil.rmtree(shell_dir)
Sebastian Noack 2015/11/19 20:21:43 I'm not sure whether this is a good idea. Imagine
kzar 2015/11/20 09:02:00 That's true, but the current behaviour is to somew
+ os.makedirs(shell_dir)
supported_platforms = {
'win32': 'win32',
@@ -40,8 +56,7 @@ def ensureJSShell():
sys.platform, platform.machine()
))
- download_url = 'https://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/2015/02/2015-02-25-00-22-19-mozilla-esr31/jsshell-%s.zip' % build
- data = StringIO(urllib.urlopen(download_url).read())
+ data = StringIO(urllib.urlopen(JSSHELL_URL % build).read())
zip = zipfile.ZipFile(data)
zip.extractall(shell_dir)
zip.close()
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld