Fixes AttributeError thrown by chocolatey state

Fixes #42521
This commit is contained in:
jmarinaro 2017-07-24 18:15:16 -06:00
parent 488457c5a0
commit b242d2d6b5

View file

@ -92,7 +92,7 @@ def installed(name, version=None, source=None, force=False, pre_versions=False,
# Determine action
# Package not installed
if name not in [package.split('|')[0].lower() for package in pre_install.splitlines()]:
if name.lower() not in [package.lower() for package in pre_install.keys()]:
if version:
ret['changes'] = {name: 'Version {0} will be installed'
''.format(version)}
@ -193,9 +193,13 @@ def uninstalled(name, version=None, uninstall_args=None, override_args=False):
pre_uninstall = __salt__['chocolatey.list'](local_only=True)
# Determine if package is installed
if name in [package.split('|')[0].lower() for package in pre_uninstall.splitlines()]:
ret['changes'] = {name: '{0} version {1} will be removed'
''.format(name, pre_uninstall[name][0])}
if name.lower() in [package.lower() for package in pre_uninstall.keys()]:
try:
ret['changes'] = {name: '{0} version {1} will be removed'
''.format(name, pre_uninstall[name][0])}
except KeyError:
ret['changes'] = {name: '{0} will be removed'
''.format(name)}
else:
ret['comment'] = 'The package {0} is not installed'.format(name)
return ret