[PATCH] 472462 - catch yum exceptions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



returnNewestByName in yum changed a while back, and we only modified our
usage of it in a couple places.  Now if no package is found, it raises a
PackageSackError instead of returning [].  This patch does the obvious.

Incidentally, this may be a candidate for an F10 updates image, if we
care enough about the only-Xen case.

- Chris


diff --git a/yuminstall.py b/yuminstall.py
index 1ec5463..05ea169 100644
--- a/yuminstall.py
+++ b/yuminstall.py
@@ -1209,9 +1209,11 @@ reposdir=/etc/anaconda.repos.d,/tmp/updates/anaconda.repos.d,/tmp/product/anacon
 
         def getBestKernelByArch(pkgname, ayum):
             """Convenience func to find the best arch of a kernel by name"""
-            pkgs = ayum.pkgSack.returnNewestByName(pkgname)
-            if len(pkgs) == 0:
+            try:
+                pkgs = ayum.pkgSack.returnNewestByName(pkgname)
+            except yum.Errors.PackageSackError:
                 return None
+
             pkgs = self.ayum.bestPackagesFromList(pkgs)
             if len(pkgs) == 0:
                 return None
@@ -1556,10 +1558,12 @@ reposdir=/etc/anaconda.repos.d,/tmp/updates/anaconda.repos.d,/tmp/product/anacon
 
     def _checkUpgradeArch(self, anaconda):
         # get the arch of the initscripts package
-        pkgs = self.ayum.pkgSack.returnNewestByName('initscripts')
-        if len(pkgs) == 0:
+        try:
+            pkgs = self.ayum.pkgSack.returnNewestByName('initscripts')
+        except yum.Errors.PackageSackError:
             log.info("no packages named initscripts")
-            return
+            return None
+
         pkgs = self.ayum.bestPackagesFromList(pkgs)
         if len(pkgs) == 0:
             log.info("no best package")

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux