Skip to content

Commit

Permalink
Pass __env__ to salt.modules.pip._get_cached_requirements
Browse files Browse the repository at this point in the history
This fixes #6003, and resolves a traceback caused by the environment not
being passed to the function.
  • Loading branch information
terminalmage committed Jul 8, 2013
1 parent 525d55b commit 6e15b50
Showing 1 changed file with 4 additions and 27 deletions.
31 changes: 4 additions & 27 deletions salt/modules/pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,8 @@
VALID_PROTOS = ['http', 'https', 'ftp']


def _get_pip_bin(bin_env):
'''
Return the pip command to call, either from a virtualenv, an argument
passed in, or from the global modules options
'''
if not bin_env:
which_result = __salt__['cmd.which_bin'](['pip2', 'pip', 'pip-python'])
if which_result is None:
raise CommandNotFoundError('Could not find a `pip` binary')
return which_result

# try to get pip bin from env
if os.path.isdir(bin_env):
if salt.utils.is_windows():
pip_bin = os.path.join(bin_env, 'Scripts', 'pip.exe')
else:
pip_bin = os.path.join(bin_env, 'bin', 'pip')
if os.path.isfile(pip_bin):
return pip_bin
raise CommandNotFoundError('Could not find a `pip` binary')

return bin_env


def _get_cached_requirements(requirements):
"""Get the location of a cached requirements file; caching if necessary."""
def _get_cached_requirements(requirements, __env__):
'''Get the location of a cached requirements file; caching if necessary.'''
cached_requirements = __salt__['cp.is_cached'](
requirements, __env__
)
Expand Down Expand Up @@ -247,7 +223,8 @@ def install(pkgs=None,
treq = None
if requirements:
if requirements.startswith('salt://'):
cached_requirements = _get_cached_requirements(requirements)
cached_requirements = _get_cached_requirements(requirements,
__env__)
if not cached_requirements:
return {
'result': False,
Expand Down

0 comments on commit 6e15b50

Please sign in to comment.