conservative check for known exceptions in subprocess stderr.

This commit is contained in:
Adam Goldschmidt
2019-01-20 13:09:28 +02:00
parent 8aa9283fda
commit 3fe5061682
+10 -2
View File
@@ -925,9 +925,17 @@ def do_create_virtualenv(python=None, site_packages=False, pypi_mirror=None):
)
click.echo(crayons.blue("{0}".format(c.out)), err=True)
if c.returncode != 0:
sp.fail(environments.PIPENV_SPINNER_FAIL_TEXT.format(u"Failed creating virtual environment"))
sp.fail(environments.PIPENV_SPINNER_FAIL_TEXT.format("Failed creating virtual environment"))
known_exceptions = {
"PermissionError": "Permission denied:",
}
# PermissionError - hide the traceback for better UX
for partition in (part
for e, part in known_exceptions.items() if e in c.err):
known_exceptions_partition = c.err.rpartition(partition)
c.err = "{} {}".format(known_exceptions_partition[1], known_exceptions_partition[2])
raise exceptions.VirtualenvCreationException(
extra=[crayons.blue("{0}".format(c.err)),]
extra=[crayons.red("{0}".format(c.err)),]
)
else: