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

Unified Diff: utils.py

Issue 29345502: Issue 4097 - Make JSHydra use SpiderMonkey location from an environment variable if available (Closed)
Patch Set: Created June 1, 2016, 1:16 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
===================================================================
--- a/utils.py
+++ b/utils.py
@@ -22,16 +22,20 @@ JSSHELL_SUPPORTED_PLATFORMS = {
"i686": "linux-i686",
"x86_64": "linux-x86_64"
},
"darwin": "mac"
}
def ensureJSShell():
+ path = os.environ.get('SPIDERMONKEY_BINARY')
+ if path and os.path.isfile(path):
+ return path
+
baseDir = os.path.dirname(__file__)
try:
build = JSSHELL_SUPPORTED_PLATFORMS[sys.platform]
if isinstance(build, dict):
build = build[platform.machine()]
except KeyError:
raise Exception('Platform %s (%s) not supported by JS shell' % (
@@ -43,17 +47,17 @@ def ensureJSShell():
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
-
+
with closing(urllib.urlopen(JSSHELL_URL % build)) as response:
data = response.read()
with zipfile.ZipFile(StringIO(data)) as zip:
zip.extractall(shell_dir)
if not os.path.exists(path):
raise Exception('Downloaded package didn\'t contain JS shell executable')
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld