Пример #1
0
    def _get_pkgname_parsers(self, db, db_opsys=None):
        """
        Query pyfaf.storage.SfPrefilterPackageName objects and turn them into
        python regexp parsers. Return a dictionary {parser: solution}.
        """

        result = {}

        db_pkgnames = get_sf_prefilter_pkgnames(db, db_opsys=db_opsys)
        for db_pkgname in db_pkgnames:
            try:
                parser = re.compile(db_pkgname.pattern)
            except re.error as ex:
                log.warn("Unable to compile pattern '{0}': {1}".format(db_pkgname.pattern, str(ex)))
                continue

            result[parser] = db_pkgname.solution

        return result
Пример #2
0
    def _get_pkgname_parsers(self, db, db_opsys=None):
        """
        Query pyfaf.storage.SfPrefilterPackageName objects and turn them into
        python regexp parsers. Return a dictionary {parser: solution}.
        """

        result = {}

        db_pkgnames = get_sf_prefilter_pkgnames(db, db_opsys=db_opsys)
        for db_pkgname in db_pkgnames:
            try:
                parser = re.compile(db_pkgname.pattern)
            except re.error as ex:
                log.warn("Unable to compile pattern '{0}': {1}".format(
                    db_pkgname.pattern, str(ex)))
                continue

            result[parser] = db_pkgname.solution

        return result
Пример #3
0
    def find_solution_ureport(self, db, ureport, osr=None):
        """
        Check whether uReport matches a knowledgebase
        entry. Return a pyfaf.storage.SfPrefilterSolution object or None.
        """

        if "ureport_version" in ureport and ureport["ureport_version"] == 1:
            ureport = ureport1to2(ureport)
            validate(ureport)

        db_opsys = None
        if osr is not None:
            db_opsys = osr.opsys

        osname = ureport["os"]["name"]
        if osname not in systems:
            log.warn("Operating system '{0}' is not supported".format(osname))
        else:
            osplugin = systems[osname]
            db_opsys = get_opsys_by_name(db, osplugin.nice_name)
            if db_opsys is None:
                log.warn("Operaring system '{0}' is not installed in storage".
                         format(osplugin.nice_name))
            else:
                pkgname_parsers = self._get_pkgname_parsers(db,
                                                            db_opsys=db_opsys)
                for parser, solution in pkgname_parsers.items():
                    if osplugin.check_pkgname_match(ureport["packages"],
                                                    parser):
                        return self._sfps_to_solution(solution)

        ptype = ureport["problem"]["type"]
        if ptype not in problemtypes:
            log.warn("Problem type '{0}' is not supported".format(ptype))
        else:
            problemplugin = problemtypes[ptype]
            btpath_parsers = self._get_btpath_parsers(db, db_opsys=db_opsys)
            for parser, solution in btpath_parsers.items():
                if problemplugin.check_btpath_match(ureport["problem"],
                                                    parser):
                    return self._sfps_to_solution(solution)

        return None
Пример #4
0
    def find_solution_ureport(self, db, ureport, osr=None):
        """
        Check whether uReport matches a knowledgebase
        entry. Return a pyfaf.storage.SfPrefilterSolution object or None.
        """

        if "ureport_version" in ureport and ureport["ureport_version"] == 1:
            ureport = ureport1to2(ureport)
            validate(ureport)

        db_opsys = None
        if osr is not None:
            db_opsys = osr.opsys

        osname = ureport["os"]["name"]
        if osname not in systems:
            log.warn("Operating system '{0}' is not supported".format(osname))
        else:
            osplugin = systems[osname]
            db_opsys = get_opsys_by_name(db, osplugin.nice_name)
            if db_opsys is None:
                log.warn("Operaring system '{0}' is not installed in storage"
                         .format(osplugin.nice_name))
            else:
                pkgname_parsers = self._get_pkgname_parsers(db, db_opsys=db_opsys)
                for parser, solution in pkgname_parsers.items():
                    if osplugin.check_pkgname_match(ureport["packages"], parser):
                        return self._sfps_to_solution(solution)

        ptype = ureport["problem"]["type"]
        if ptype not in problemtypes:
            log.warn("Problem type '{0}' is not supported".format(ptype))
        else:
            problemplugin = problemtypes[ptype]
            btpath_parsers = self._get_btpath_parsers(db, db_opsys=db_opsys)
            for parser, solution in btpath_parsers.items():
                if problemplugin.check_btpath_match(ureport["problem"], parser):
                    return self._sfps_to_solution(solution)

        return None
Пример #5
0
 def _flush_session(self, *args, **kwargs):
     if self._dry:
         log.warn("Dry run enabled, not flushing the database")
     else:
         self.session._flush_orig(*args, **kwargs)
Пример #6
0
 def _flush_session(self, *args, **kwargs):
     if self._dry:
         log.warn("Dry run enabled, not flushing the database")
     else:
         self.session._flush_orig(*args, **kwargs)