[yum-commits] Branch 'yum-3_2_X' - 2 commits - yum/__init__.py yum/depsolve.py yummain.py

James Antill james at osuosl.org
Mon Apr 6 21:42:29 UTC 2009


 yum/__init__.py |   17 +++++++++++++++--
 yum/depsolve.py |    8 +++++++-
 yummain.py      |    1 +
 3 files changed, 23 insertions(+), 3 deletions(-)

New commits:
commit 61fe5b2c4560f4ea8e4bc15e75ed35d6af5f9335
Author: James Antill <james at and.org>
Date:   Mon Apr 6 17:37:38 2009 -0400

     Add message function about pkgs that are in yum-utils, BZ 494432.

diff --git a/yum/__init__.py b/yum/__init__.py
index ee27ce4..6a22e85 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -687,15 +687,28 @@ class YumBase(depsolve.Depsolve):
             self.verbose_logger.log(logginglevels.INFO_2, msg)
             self.repos.populateSack(mdtype='filelists')
            
+    def yumUtilsMsg(self, func, prog):
+        """ Output a message that the tool requires the yum-utils package,
+            if not installed. """
+        if self.rpmdb.contains(name="yum-utils"):
+            return
+
+        hibeg, hiend = "", ""
+        if hasattr(self, 'term'):
+            hibeg, hiend = self.term.MODE['bold'], self.term.MODE['normal']
+
+        func(_("The program %s%s%s is found in the yum-utils package.") %
+             (hibeg, prog, hiend))
+
     def buildTransaction(self, unfinished_transactions_check=True):
         """go through the packages in the transaction set, find them in the
            packageSack or rpmdb, and pack up the ts accordingly"""
         if (unfinished_transactions_check and
             misc.find_unfinished_transactions(yumlibpath=self.conf.persistdir)):
             msg = _('There are unfinished transactions remaining. You might ' \
-                    'consider running yum-complete-transaction (found in the ' \
-                    'yum-utils package) first to finish them.' )
+                    'consider running yum-complete-transaction first to finish them.' )
             self.logger.critical(msg)
+            base.yumUtilsMsg(self.logger.critical, "yum-complete-transaction")
             time.sleep(3)
 
         self.plugins.run('preresolve')
diff --git a/yummain.py b/yummain.py
index 93cea0a..30fb831 100755
--- a/yummain.py
+++ b/yummain.py
@@ -241,6 +241,7 @@ def main(args):
         verbose_logger.info(_(" You could try running: package-cleanup --problems\n"
                               "                        package-cleanup --dupes\n"
                               "                        rpm -Va --nofiles --nodigest"))
+        base.yumUtilsMsg(verbose_logger.info, "package-cleanup")
         if unlock(): return 200
         return 1
     elif result == 2:
commit 0b256922a37027e5467324f660586e1cd7d5ee5d
Author: James Antill <james at and.org>
Date:   Mon Apr 6 11:23:57 2009 -0400

    Sort pkgs normally, which have the same score.

diff --git a/yum/depsolve.py b/yum/depsolve.py
index 48e3c65..819adac 100644
--- a/yum/depsolve.py
+++ b/yum/depsolve.py
@@ -996,6 +996,12 @@ class Depsolve(object):
         self.verbose_logger.log(logginglevels.DEBUG_4,
               _("Running compare_providers() for %s") %(str(pkgs)))
 
+        def _cmp_best_providers(x, y):
+            """ Compare first by score, and then compare the pkgs if the score
+                is the same. Note that this sorts in reverse. """
+            ret = cmp(y[1], x[1])
+            if ret: return ret
+            return cmp(y[0], x[0])
         
         def _common_prefix_len(x, y, minlen=2):
             num = min(len(x), len(y))
@@ -1121,7 +1127,7 @@ class Depsolve(object):
             
             pkgresults[po] += (len(po.name)*-1)
 
-        bestorder = sorted(pkgresults.items(), key=itemgetter(1), reverse=True)
+        bestorder = sorted(pkgresults.items(), cmp=_cmp_best_providers)
         self.verbose_logger.log(logginglevels.DEBUG_4,
                 _('Best Order: %s' % str(bestorder)))
 


More information about the Yum-commits mailing list