Show the packages found when installing at DEBUG level.

When attempting to ensure all desired packages at the
right versions are still findable not only print out
that we could find them, but also DEBUG the
information retrieved about the package, which will be
useful in cases where someone wants to look at the debug
output to verify whats going to be installed.

Change-Id: I78de10091740d7c383f415889eaa3aeaad27dcf8
This commit is contained in:
Joshua Harlow 2013-08-06 19:21:48 -07:00
parent 4d18d82c3e
commit 3a2e9e0f72
2 changed files with 18 additions and 10 deletions

View File

@ -688,7 +688,7 @@ class YumDependencyHandler(base.DependencyHandler):
pkg = json.loads(matched)
if isinstance(pkg, dict):
rpm_names_located.add(pkg['name'])
rpms_located.append((pkg['name'], pkg['version']))
rpms_located.append(pkg)
rpm_names_missing = desired_rpm_names - rpm_names_located
if rpm_names_missing:
@ -709,8 +709,9 @@ class YumDependencyHandler(base.DependencyHandler):
LOG.info("All %s required packages are still available!", len(desired_rpms))
desired_rpms = []
for (name, version) in rpms_located:
desired_rpms.append("%s,%s" % (name, version))
for pkg in rpms_located:
LOG.debug("Found %s", pkg)
desired_rpms.append("%s,%s" % (pkg['name'], pkg['version']))
return list(sorted(desired_rpms))
def install(self):

View File

@ -28,6 +28,19 @@ import pkg_resources
from yum import YumBase
def format_rpm(pkg):
details = {
'arch': pkg.arch,
'epoch': pkg.epoch,
'name': pkg.name,
'release': pkg.release,
'version': pkg.version,
}
if hasattr(pkg, 'repo') and pkg.repo:
details['repo'] = pkg.repo.name
return details
def parse_py_req(text):
if not text:
return None
@ -86,13 +99,7 @@ if __name__ == '__main__':
# Pick the newest match.
pkg = sorted(matches)[-1]
if options.is_json:
print(json.dumps({
'arch': pkg.arch,
'epoch': pkg.epoch,
'name': pkg.name,
'release': pkg.release,
'version': pkg.version,
}))
print(json.dumps(format_rpm(pkg)))
else:
print(pkg)
else: