Maintain stateful output if something went wrong running the pip command

This commit is contained in:
rallytime 2015-10-15 16:10:02 -06:00
parent 5bcc89bb8e
commit 9855290b99

View file

@ -173,13 +173,13 @@ def _check_if_installed(prefix, state_pkg_name, version_spec,
# result: False means the package is not installed
ret = {'result': False, 'comment': None}
# Check if the requested packated is already installed.
# Check if the requested package is already installed.
try:
pip_list = __salt__['pip.list'](prefix, bin_env=bin_env,
user=user, cwd=cwd)
prefix_realname = _find_key(prefix, pip_list)
except (CommandNotFoundError, CommandExecutionError) as err:
ret['result'] = False
ret['result'] = None
ret['comment'] = 'Error installing {0!r}: {1}'.format(state_pkg_name,
err)
return ret
@ -597,7 +597,6 @@ def installed(name,
target_pkgs = []
already_installed_comments = []
if requirements or editable:
name = ''
comments = []
# Append comments if this is a dry run.
if __opts__['test']:
@ -626,6 +625,12 @@ def installed(name,
out = _check_if_installed(prefix, state_pkg_name, version_spec,
ignore_installed, force_reinstall,
upgrade, user, cwd, bin_env)
# If _check_if_installed result is None, something went wrong with
# the command running. This way we keep stateful output.
if out['result'] is None:
ret['result'] = False
ret['comment'] = out['comment']
return ret
else:
out = {'result': False, 'comment': None}