From d6b190a12ef81058411033f8683fd7e35a13745e Mon Sep 17 00:00:00 2001
From: Dan Callaghan <dcallagh@redhat.com>
Date: Fri, 19 Sep 2014 16:33:09 +1000
Subject: [PATCH 1/2] check .count() of rpm.mi objects instead of relying on
bool coercion
Older versions of RPM (including the version in RHEL5 and earlier) did
not implement bool coercion for rpm.mi objects, they are always true
even if they contain no matches. len() is also not implemented. So we
need to check .count() before we can assume there are any matches.
Bug: 1142535
---
src/python/journalling.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/python/journalling.py b/src/python/journalling.py
index b7ede6d..e404742 100755
--- a/src/python/journalling.py
+++ b/src/python/journalling.py
@@ -296,7 +296,7 @@ class Journal(object):
return None
testInfo = ts.dbMatch("name", package)
- if not testInfo:
+ if not testInfo.count():
return None
buildtime = time.gmtime(int(testInfo.next().format("%{BUILDTIME}")))
@@ -384,7 +384,7 @@ class Journal(object):
ts = rpm.ts()
mi = ts.dbMatch("name", "beakerlib")
beakerlibRpmEl = newdoc.createElement("beakerlib_rpm")
- if mi:
+ if mi.count():
beakerlib_rpm = mi.next()
beakerlibRpmCon = newdoc.createTextNode("%(name)s-%(version)s-%(release)s " % beakerlib_rpm)
else:
@@ -392,7 +392,7 @@ class Journal(object):
mi = ts.dbMatch("name", "beakerlib-redhat")
beakerlibRedhatRpmEl = newdoc.createElement("beakerlib_redhat_rpm")
- if mi:
+ if mi.count():
beakerlib_redhat_rpm = mi.next()
beakerlibRedhatRpmCon = newdoc.createTextNode("%(name)s-%(version)s-%(release)s " % beakerlib_redhat_rpm)
else:
--
1.9.3