[yum-cvs] yum cli.py,1.241.2.11,1.241.2.12

James Bowes jbowes at linux.duke.edu
Sat Feb 3 17:09:29 UTC 2007


Update of /home/groups/yum/cvs/yum
In directory login1.linux.duke.edu:/tmp/cvs-serv15889

Modified Files:
      Tag: yum-3_0_X
	cli.py 
Log Message:
Patch from Brian Wheeler for a nicer error summary of required disk space

Index: cli.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/cli.py,v
retrieving revision 1.241.2.11
retrieving revision 1.241.2.12
diff -u -r1.241.2.11 -r1.241.2.12
--- cli.py	3 Feb 2007 16:04:28 -0000	1.241.2.11
+++ cli.py	3 Feb 2007 17:09:27 -0000	1.241.2.12
@@ -17,6 +17,7 @@
 
 
 import os
+import re
 import sys
 import time
 import random
@@ -336,6 +337,30 @@
             yumshell.script()
         return yumshell.result, yumshell.resultmsgs
 
+    def errorSummary(self, errstring):
+        """ parse the error string for 'interesting' errors which can
+            be grouped, such as disk space issues """
+        summary = ''
+        # do disk space report first
+        p = re.compile('needs (\d+)MB on the (\S+) filesystem')
+        disk = {}
+        for m in p.finditer(errstring):
+           if not disk.has_key(m.group(2)):
+              disk[m.group(2)]=0
+           disk[m.group(2)] += int(m.group(1))
+        if disk.keys():
+           summary += 'Disk Requirements:\n'
+           for k in disk.keys():
+              summary += '  At least %dMB needed on the %s filesystem.\n' % (disk[k], k)
+
+        # TODO: simplify the dependency errors?
+
+        # Fixup the summary
+        summary = 'Error Summary\n-------------\n' + summary
+              
+        return summary
+
+
     def doCommands(self):
         """calls the base command passes the extended commands/args out to be
         parsed. (most notably package globs). returns a numeric result code and
@@ -426,11 +451,12 @@
         self.verbose_logger.log(yum.logginglevels.INFO_2,
             'Finished Transaction Test')
         if len(tserrors) > 0:
-            errstring = 'Transaction Check Error: '
+            errstring = 'Transaction Check Error:\n'
             for descr in tserrors:
                 errstring += '  %s\n' % descr 
             
-            raise yum.Errors.YumBaseError, errstring
+            raise yum.Errors.YumBaseError, errstring + '\n' + \
+                 self.errorSummary(errstring)
         self.verbose_logger.log(yum.logginglevels.INFO_2,
              'Transaction Test Succeeded')
         del self.ts




More information about the Yum-cvs-commits mailing list