[Kimchi-devel] [PATCH] Github 663: software update improvements

dhbarboza82 at gmail.com dhbarboza82 at gmail.com
Thu Jun 25 20:12:23 UTC 2015


From: Daniel Henrique Barboza <dhbarboza82 at gmail.com>

- started considering just the return code of yum check-update
instead of the existence of error output

- ignoring any package declared after the 'Obsoleting Packages'
warning

Signed-off-by: Daniel Henrique Barboza <dhbarboza82 at gmail.com>
---
 src/kimchi/yumparser.py | 14 +++++++++++++-
 tests/test_yumparser.py |  5 ++---
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/kimchi/yumparser.py b/src/kimchi/yumparser.py
index 8151f86..792c3ae 100644
--- a/src/kimchi/yumparser.py
+++ b/src/kimchi/yumparser.py
@@ -229,10 +229,21 @@ def _include_line_checkupdate_output(line):
     return True
 
 
+def _ignore_obsoleting_packages_in(output):
+    out = ''
+    for l in output.split('\n'):
+        if 'Obsoleting ' in l:
+            break
+        out += l + '\n'
+    return out
+
+
 def _filter_lines_checkupdate_output(output):
     if output is None:
         return []
 
+    output = _ignore_obsoleting_packages_in(output)
+
     out = [l for l in output.split('\n')
            if _include_line_checkupdate_output(l)]
     return out
@@ -244,7 +255,8 @@ def _get_yum_checkupdate_output():
                                       stdout=subprocess.PIPE,
                                       stderr=subprocess.PIPE)
     out, error = yum_update_cmd.communicate()
-    if error != '':
+    return_code = yum_update_cmd.returncode
+    if return_code == 1:
         return None
 
     return out
diff --git a/tests/test_yumparser.py b/tests/test_yumparser.py
index 69f411a..53a2d80 100644
--- a/tests/test_yumparser.py
+++ b/tests/test_yumparser.py
@@ -154,9 +154,8 @@ class YumParserTests(unittest.TestCase):
     def test_yum_checkupdate_parsing(self):
         output = _generate_yumcheckupdate_output()
         packages = get_yum_packages_list_update(output)
-        self.assertEqual(len(packages), 5)
+        self.assertEqual(len(packages), 3)
         self.assertEqual(packages[0].ui_from_repo, 'REPOSITORY1')
         self.assertEqual(packages[1].version, '20150611.-no-FAKE2')
         self.assertEqual(packages[2].name, 'PACKAGE3.dot.dot')
-        self.assertEqual(packages[3].arch, 'i386')
-        self.assertEqual(packages[4].arch, 'fakearch')
+        self.assertEqual(packages[2].arch, 'i386')
-- 
2.4.3




More information about the Kimchi-devel mailing list