Auto merge of #7678 - AnthonyBroadCrawford:improved-error-messaging-mach-bootstrap, r=frewsxcv

#7630 Adding better error messaging in mach bootstrap for missing virtualenv/pip dependencies 

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

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7678)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-09-21 18:13:35 -06:00
commit 44de9173cc

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)