servo: Merge #7678 - #7630 Adding better error messaging in mach bootstrap for missing virtualenv/pip dependencies (from AnthonyBroadCrawford:improved-error-messaging-mach-bootstrap); r=frewsxcv

This PR is in reference to #7630

I've added a simple try catch around our use of subprocess.check_all when trying to invoke and use python's

- virtualenv
- pip

Upon failure, I use sys.exit with an error message for the user.  Exit seemed appropriate as anything beneath those dependencies will fail to execute and result in a non friendly error message

Source-Repo: https://github.com/servo/servo
Source-Revision: 44de9173cc968957e4441c14f57014111a2b847e
This commit is contained in:
Anthony Broad-Crawford 2015-09-21 18:13:35 -06:00
parent 9d1c1d282d
commit 6c86215e3e

View File

@ -84,7 +84,14 @@ def _activate_virtualenv(topdir):
if not os.path.exists(virtualenv_path):
virtualenv = _get_exec("virtualenv2", "virtualenv")
subprocess.check_call([virtualenv, "-p", python, virtualenv_path])
try:
subprocess.check_call([virtualenv, "-p", python, virtualenv_path])
except subprocess.CalledProcessError:
sys.exit("Python virtualenv failed to execute properly.")
except OSError:
sys.exit("Please install virtualenv "
"and ensure permissions prior to running mach.")
activate_path = os.path.join(virtualenv_path, "bin", "activate_this.py")
execfile(activate_path, dict(__file__=activate_path))
@ -109,7 +116,15 @@ def _activate_virtualenv(topdir):
continue
except OSError:
open(marker_path, 'w').close()
subprocess.check_call(["pip", "install", "-q", "-r", req_path])
try:
subprocess.check_call(["pip", "install", "-q", "-r", req_path])
except subprocess.CalledProcessError:
sys.exit("Pip failed to execute properly.")
except OSError:
sys.exit("Pip not found. Please install pip and verify permissions"
" prior to running mach.")
os.utime(marker_path, None)