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

Re: [PATCH] 472462 - catch yum exceptions



Chris Lumens wrote:
> 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")

Looks good.

-- 
David Cantrell <dcantrell redhat com>
Red Hat / Honolulu, HI


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