Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions virtualenvapi/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ def _execute_pip(self, args, log=True):

def _execute(self, args, log=True):
"""Executes the given command inside the environment and returns the output."""

if not self._ready:
self.open_or_create()
output = ''
Expand All @@ -149,11 +150,11 @@ def _execute(self, args, log=True):
prog = args[0]
if prog[0] != os.sep:
prog = os.path.join(self.path, prog)
raise OSError('%s: %s' % (prog, six.u(str(e))))
six.raise_from(OSError('%s: %s' % (prog, six.u(str(e)))), e)
except subprocess.CalledProcessError as e:
output, error = e.output
e.output = output
raise e
six.raise_from(e, e)
finally:
if log:
try:
Expand Down Expand Up @@ -227,7 +228,7 @@ def install(self, package, force=False, upgrade=False, options=None):
try:
self._execute_pip(['install'] + package_args + options)
except subprocess.CalledProcessError as e:
raise PackageInstallationException((e.returncode, e.output, package))
six.raise_from(PackageInstallationException((e.returncode, e.output, package)), e)

def uninstall(self, package):
"""Uninstalls the given package (given in pip's package syntax or a tuple of
Expand All @@ -240,7 +241,7 @@ def uninstall(self, package):
try:
self._execute_pip(['uninstall', '-y', package])
except subprocess.CalledProcessError as e:
raise PackageRemovalException((e.returncode, e.output, package))
six.raise_from(PackageRemovalException((e.returncode, e.output, package)), e)

def wheel(self, package, options=None):
"""Creates a wheel of the given package from this virtual environment,
Expand All @@ -266,7 +267,7 @@ def wheel(self, package, options=None):
try:
self._execute_pip(['wheel', package] + options)
except subprocess.CalledProcessError as e:
raise PackageWheelException((e.returncode, e.output, package))
six.raise_from(PackageWheelException((e.returncode, e.output, package)), e)

def is_installed(self, package):
"""Returns True if the given package (given in pip's package syntax or a
Expand Down