def check_rpm_qa()

in dcrpm/rpmutil.py [0:0]


    def check_rpm_qa(self):
        # type: () -> None
        """
        Runs `rpm -qa` which serves as a good proxy check for whether bdb needs recovery
        """
        try:
            result = run_with_timeout(
                [self.rpm_path, "--dbpath", self.dbpath, "-qa"], RPM_CHECK_TIMEOUT_SEC
            )
        except DcRPMException:
            self.logger.error("rpm -qa failed")
            self.status_logger.warning("initial_db_check_fail")
            raise DBNeedsRecovery()

        packages = result.stdout.strip().split()
        # This test only makes sense on Linux; on macOS RPM is not the native
        # package manager, so a freshly-installed system can have
        # very few RPMs
        if read_os_name() == "Linux":
            if len(packages) < MIN_ACCEPTABLE_PKG_COUNT:
                self.logger.error(
                    "rpm package count seems too low; saw %d, expected at least %d",
                    len(packages),
                    MIN_ACCEPTABLE_PKG_COUNT,
                )
                raise DBNeedsRecovery()

        self.logger.debug("Package count: %d", len(packages))