mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #35207 from eliasp/2016.3-modules.aptpkg-handle-exceptions
Handle exceptions in `_get_virtual()` and in `_get_virtual()` consumers
This commit is contained in:
commit
100645e557
1 changed files with 14 additions and 3 deletions
|
@ -171,7 +171,12 @@ def _get_virtual():
|
|||
except KeyError:
|
||||
__context__['pkg._get_virtual'] = {}
|
||||
if HAS_APT:
|
||||
apt_cache = apt.cache.Cache()
|
||||
try:
|
||||
apt_cache = apt.cache.Cache()
|
||||
except SystemError as se:
|
||||
msg = 'Failed to get virtual package information ({0})'.format(se)
|
||||
log.error(msg)
|
||||
raise CommandExecutionError(msg)
|
||||
pkgs = getattr(apt_cache._cache, 'packages', [])
|
||||
for pkg in pkgs:
|
||||
for item in getattr(pkg, 'provides_list', []):
|
||||
|
@ -249,7 +254,10 @@ def latest_version(*names, **kwargs):
|
|||
if refresh:
|
||||
refresh_db()
|
||||
|
||||
virtpkgs = _get_virtual()
|
||||
try:
|
||||
virtpkgs = _get_virtual()
|
||||
except CommandExecutionError as cee:
|
||||
raise CommandExecutionError(cee)
|
||||
all_virt = set()
|
||||
for provides in six.itervalues(virtpkgs):
|
||||
all_virt.update(provides)
|
||||
|
@ -1179,7 +1187,10 @@ def list_pkgs(versions_as_list=False,
|
|||
|
||||
# Check for virtual packages. We need dctrl-tools for this.
|
||||
if not removed:
|
||||
virtpkgs_all = _get_virtual()
|
||||
try:
|
||||
virtpkgs_all = _get_virtual()
|
||||
except CommandExecutionError as cee:
|
||||
raise CommandExecutionError(cee)
|
||||
virtpkgs = set()
|
||||
for realpkg, provides in six.iteritems(virtpkgs_all):
|
||||
# grep-available returns info on all virtual packages. Ignore any
|
||||
|
|
Loading…
Add table
Reference in a new issue