Esempio n. 1
0
File: ureport.py Progetto: abrt/faf
def is_known(ureport, db, return_report=False, opsysrelease_id=None):
    ureport = ureport2(ureport)
    validate(ureport)

    problemplugin = problemtypes[ureport["problem"]["type"]]
    report_hash = problemplugin.hash_ureport(ureport["problem"])

    known_type = []

    # Split allowed types from config
    if 'ureport.known' in config and config['ureport.known'].strip() != "":
        known_type = config['ureport.known'].strip().split(" ")

    if known_type and not valid_known_type(known_type):
        return None

    report_os = {'name':None,
                 'version':None,
                 'architecture':None}

    if 'EQUAL_UREPORT_EXISTS' in known_type:
        report_os = ureport["os"]

    report = get_report(db, report_hash, os_name=report_os['name'], os_version=report_os['version'],
                        os_arch=report_os['architecture'])

    if report is None:
        return None

    found = False

    if 'EQUAL_UREPORT_EXISTS' in known_type:

        found = True

    elif ('BUG_OS_MINOR_VERSION' in known_type and
          get_reportbz(db, report.id, opsysrelease_id).first() is not None):

        found = True
    elif ('BUG_OS_MAJOR_VERSION' in known_type and
          get_reportbz_by_major_version(db, report.id,
                                        major_version=ureport["os"]["version"]
                                        .split(".")[0])
          .first() is not None):

        found = True

    elif not known_type:
        bzs = get_reportbz(db, report.id, opsysrelease_id).all()
        for bz in bzs:
            if not bz.bzbug.private:
                found = True
                break

    if found:
        if return_report:
            return report
        return True

    return None
Esempio n. 2
0
def is_known(ureport, db, return_report=False, opsysrelease_id=None):
    ureport = ureport2(ureport)

    problemplugin = problemtypes[ureport["problem"]["type"]]
    report_hash = problemplugin.hash_ureport(ureport["problem"])

    report = get_report_by_hash(db, report_hash)

    if report is None:
        return None
    if get_reportbz(db, report.id, opsysrelease_id).first() is not None:
        if return_report:
            return report
        return True

    return None