Skip to content

Commit

Permalink
added error checking for Red Hat packages scan which was throwing an …
Browse files Browse the repository at this point in the history
…exception when a system with no RH packages was scaned.
  • Loading branch information
mvickstr committed Feb 11, 2016
1 parent 788b3aa commit 975237b
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions src/rho/rho_cmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,26 @@ def parse_data(self):
return
installed_packages = [PkgInfo(line, "|") for line in self.cmd_results[0][0].splitlines()]
rh_packages = filter(PkgInfo.is_red_hat_pkg, installed_packages)
last_installed = max(rh_packages, key=lambda x: x.install_time)
last_built = max(rh_packages, key=lambda x: x.build_time)
is_red_hat = "Y" if len(rh_packages) > 0 else "N"
self.data['redhat-packages.is_redhat'] = is_red_hat
self.data['redhat-packages.num_rh_packages'] = len(rh_packages)
self.data['redhat-packages.num_installed_packages'] = len(installed_packages)
self.data['redhat-packages.last_installed'] = last_installed.details_install()
self.data['redhat-packages.last_built'] = last_built.details_built()
if len(rh_packages) > 0:
last_installed = max(rh_packages, key=lambda x: x.install_time)
last_built = max(rh_packages, key=lambda x: x.build_time)
is_red_hat = "Y" if len(rh_packages) > 0 else "N"

self.data['redhat-packages.is_redhat'] = is_red_hat
self.data['redhat-packages.num_rh_packages'] = len(rh_packages)
self.data['redhat-packages.num_installed_packages'] = len(installed_packages)
self.data['redhat-packages.last_installed'] = last_installed.details_install()
self.data['redhat-packages.last_built'] = last_built.details_built()
else:
last_installed = ""
last_built = ""
is_red_hat = ""

self.data['redhat-packages.is_redhat'] = is_red_hat
self.data['redhat-packages.num_rh_packages'] = len(rh_packages)
self.data['redhat-packages.num_installed_packages'] = len(installed_packages)
self.data['redhat-packages.last_installed'] = last_installed
self.data['redhat-packages.last_built'] = last_built


class RedhatReleaseRhoCmd(RhoCmd):
Expand Down

0 comments on commit 975237b

Please sign in to comment.