Put pkg.latest_version in try/except structure

Move refreshed or refresh to different spot (just for code tidyness)
This commit is contained in:
Michael Walton 2016-07-25 13:22:17 -04:00
parent e0b6261659
commit e1fcb8311d

View file

@ -1056,9 +1056,17 @@ def installed(
was_refreshed = False
if version is not None and version == 'latest':
version = __salt__['pkg.latest_version'](name,
fromrepo=fromrepo,
refresh=refresh)
try:
version = __salt__['pkg.latest_version'](name,
fromrepo=fromrepo,
refresh=refresh)
except CommandExecutionError as exc:
return {'name': name,
'changes': {},
'result': False,
'comment': 'An error was encountered while checking the '
'newest available version of package(s): {0}'
.format(exc)}
was_refreshed = refresh
refresh = False
@ -1228,7 +1236,6 @@ def installed(
reinstall=reinstall,
normalize=normalize,
**kwargs)
was_refreshed = was_refreshed or refresh
except CommandExecutionError as exc:
ret = {'name': name,
'changes': {},
@ -1239,6 +1246,8 @@ def installed(
ret['comment'] += '.' + '. '.join(warnings) + '.'
return ret
was_refreshed = was_refreshed or refresh
if isinstance(pkg_ret, dict):
changes['installed'].update(pkg_ret)
elif isinstance(pkg_ret, six.string_types):