def check_tables()

in dcrpm/rpmutil.py [0:0]


    def check_tables(self):
        # type: () -> None
        """
        Runs the equivalent of:

          `rpm -qa --qf | sort | uniq | xargs rpm -q | grep 'is not installed$'`

        which checks each rpm in the DB to see if there are inconsistencies between what
        rpm thinks is installed and what is in the DB.
        """
        try:
            result = run_with_timeout(
                [self.rpm_path, "--dbpath", self.dbpath, "-qa", "--qf", "%{NAME}\\n"],
                timeout=RPM_CHECK_TIMEOUT_SEC,
                exception_to_raise=DBNeedsRebuild,
            )

            # Assume healthy if no RPMs listed.
            rpms = sorted(set(result.stdout.splitlines()))
            if not rpms:
                return
            result = run_with_timeout(
                [self.rpm_path, "--dbpath", self.dbpath, "-q"] + rpms,
                timeout=RPM_CHECK_TIMEOUT_SEC,
                exception_to_raise=DBNeedsRebuild,
            )

        except DcRPMException as e:
            self.status_logger.warning("initial_table_check_fail")
            raise

        lines = result.stdout.splitlines()
        if any([line.endswith("is not installed") for line in lines]):
            raise DBNeedsRebuild()