Expect KB as well as MB in disk requirements message from rpm. BZ 1051931 master
authorValentina Mukhamedzhanova <vmukhame@redhat.com>
Tue, 9 Dec 2014 09:27:40 +0000 (10:27 +0100)
committerValentina Mukhamedzhanova <vmukhame@redhat.com>
Tue, 9 Dec 2014 09:27:40 +0000 (10:27 +0100)
cli.py

diff --git a/cli.py b/cli.py
index b7f5b5a..f04fe63 100755 (executable)
--- a/cli.py
+++ b/cli.py
@@ -498,13 +498,14 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
         """
         summary = ''
         # do disk space report first
-        p = re.compile('needs (\d+)MB on the (\S+) filesystem')
+        p = re.compile('needs (\d+)(K|M)B on the (\S+) filesystem')
         disk = {}
         for m in p.finditer(errstring):
-            if m.group(2) not in disk:
-                disk[m.group(2)] = int(m.group(1))
-            if disk[m.group(2)] < int(m.group(1)):
-                disk[m.group(2)] = int(m.group(1))
+            size_in_mb = int(m.group(1)) if m.group(2) == 'M' else round(int(m.group(1))/1024.0, 3)
+            if m.group(3) not in disk:
+                disk[m.group(3)] = size_in_mb
+            if disk[m.group(3)] < size_in_mb:
+                disk[m.group(3)] = size_in_mb
                 
         if disk:
             summary += _('Disk Requirements:\n')