diff options
author | Bryn M. Reeves <bmr@redhat.com> | 2012-12-06 13:43:29 +0000 |
---|---|---|
committer | Bryn M. Reeves <bmr@redhat.com> | 2012-12-06 13:55:07 +0000 |
commit | 3cce6b26999bab1fa2770445aa06d994387b1d55 (patch) | |
tree | 6d3dd3b17b87f5480c656c191c468c1507abaf09 | |
parent | 6da2ca7e6bc5f0a643c992808ec93e3ba998bd4a (diff) | |
download | sos-3cce6b26999bab1fa2770445aa06d994387b1d55.tar.gz |
Fix PacakgeManager.pkgByName()
Fix a typo that prevents any package manager queries from
succeeding and change the wrapper function to explicitly test
the results list rather than relying on an exception to detect
an empty result set.
-rw-r--r-- | sos/policies/__init__.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/sos/policies/__init__.py b/sos/policies/__init__.py index 220bec8c..f245ac2f 100644 --- a/sos/policies/__init__.py +++ b/sos/policies/__init__.py @@ -6,7 +6,10 @@ import platform import time import fnmatch -from sos.utilities import ImporterHelper, import_module, get_hash_name +from sos.utilities import ImporterHelper, \ + import_module, \ + get_hash_name, \ + shell_out from sos.plugins import IndependentPlugin from sos import _sos as _ import hashlib @@ -69,9 +72,10 @@ class PackageManager(object): """ Return a single package that matches name. """ - try: - self.AllPkgsByName(name)[-1] - except Exception: + pkgmatches = self.allPkgsByName(name) + if (len(pkgmatches) != 0): + return self.allPkgsByName(name)[-1] + else: return None def getPackageList(self): |