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
def bthash_forward(bthash=None): # single hash if bthash is not None: db_report = get_report(db, bthash) if db_report is None: raise abort(404) if len(db_report.backtraces) < 1: return render_template("reports/waitforit.html") if db_report.problem is None: return render_template("problems/waitforit.html") return redirect( url_for("problems.item", problem_id=db_report.problem.id)) else: # multiple hashes as get params hashes = request.values.getlist('bth') if hashes: problems = ( db.session.query(Problem).join(Report).join(ReportHash).filter( ReportHash.hash.in_(hashes)).distinct(Problem.id).all()) if len(problems) == 0: abort(404) elif len(problems) == 1: return redirect( url_for("problems.item", problem_id=problems[0].id)) else: return render_template("problems/multiple_bthashes.html", problems=problems) else: abort(404)
def bthash_forward(bthash=None): # single hash if bthash is not None: db_report = get_report(db, bthash) if db_report is None: raise abort(404) if len(db_report.backtraces) < 1: return render_template("reports/waitforit.html") if db_report.problem is None: return render_template("problems/waitforit.html") return redirect(url_for("problems.item", problem_id=db_report.problem.id)) else: # multiple hashes as get params hashes = request.values.getlist('bth') if hashes: problems = (db.session.query(Problem) .join(Report) .join(ReportHash) .filter(ReportHash.hash.in_(hashes)) .distinct(Problem.id) .all()) if len(problems) == 0: abort(404) elif len(problems) == 1: return redirect(url_for("problems.item", problem_id=problems[0].id)) else: return render_template("problems/multiple_bthashes.html", problems=problems) else: abort(404)
def bthash_forward(bthash) -> Union[WzResponse, Tuple[str, int]]: db_report = get_report(db, bthash) if db_report is None: return render_template("reports/waitforit.html"), 404 if not db_report.backtraces: return render_template("reports/waitforit.html"), 404 return redirect(url_for("reports.item", report_id=db_report.id))
def bthash_forward(bthash): db_report = get_report(db, bthash) if db_report is None: return render_template("reports/waitforit.html"), 404 if not db_report.backtraces: return render_template("reports/waitforit.html"), 404 return redirect(url_for("reports.item", report_id=db_report.id))
def _get_db_report(self, db, ureport): ureport = ureport2(ureport) problemplugin = problemtypes[ureport["problem"]["type"]] report_hash = problemplugin.hash_ureport(ureport["problem"]) report = get_report(db, report_hash) if report is None: return None return report
def bthash_forward(bthash=None): # single hash # component ids can't be accessed through components_form object because of # redirection, it must be passed to the item function as an parameter if request.method == 'POST': component_names = request.form.get('component_names') else: component_names = None if bthash is not None: db_report = get_report(db, bthash) if db_report is None: raise abort(404) if not db_report.backtraces: return render_template("reports/waitforit.html") if db_report.problem is None: return render_template("problems/waitforit.html") return redirect(url_for("problems.item", problem_id=db_report.problem.id, component_names=component_names)) # multiple hashes as get params hashes = request.values.getlist('bth') if hashes: problems_ = (db.session.query(Problem) .join(Report) .join(ReportHash) .filter(ReportHash.hash.in_(hashes)) .distinct(Problem.id) .all()) if not problems_: abort(404) if len(problems_) == 1: return redirect(url_for("problems.item", problem_id=problems_[0].id, component_names=component_names)) return render_template("problems/multiple_bthashes.html", problems=problems_) return abort(404)
def run(self, cmdline, db) -> None: mbt = bugtrackers["centos-mantisbt"] db_tracker = get_bugtracker_by_name(db, "centos-mantisbt") for bug_id in mbt.list_bugs(): self.log_info("Processing Mantis issue #{0}".format(bug_id)) bug = mbt.mc.mc_issue_get(mbt.user, mbt.password, bug_id) bug_dict = mbt.preprocess_bug(bug) if bug_dict and bug_dict.get("url", False): url = bug_dict["url"] report_hash = url.split("/")[-1] db_report = get_report(db, report_hash) if db_report is None: self.log_info( "Report with hash {0} not found.".format(report_hash)) continue db_mantisbug = get_mantis_bug(db, bug_id, db_tracker.id) if db_mantisbug is None: self.log_info("Downloading bug to storage...") db_mantisbug = mbt.download_bug_to_storage(db, bug_id) if db_mantisbug is None: self.log_info("Failed to download bug.") continue db_rm = (db.session.query(ReportMantis).filter( ReportMantis.report == db_report).filter( ReportMantis.mantisbug == db_mantisbug).first()) if db_rm is None: db_rm = ReportMantis() db_rm.mantisbug = db_mantisbug db_rm.report = db_report db.session.add(db_rm) db.session.flush() self.log_info( "Associated issue #{0} with report #{1}.".format( bug_id, db_report.id)) else: self.log_info( "Bug {0} is not a valid ABRT issue.".format(bug_id))
def run(self, cmdline, db): mbt = bugtrackers["centos-mantisbt"] db_tracker = get_bugtracker_by_name(db, "centos-mantisbt") for bug_id in mbt.list_bugs(): self.log_info("Processing Mantis issue #{0}".format(bug_id)) bug = mbt.mc.mc_issue_get(mbt.user, mbt.password, bug_id) bug_dict = mbt._preprocess_bug(bug) if bug_dict and bug_dict.get("url", False): url = bug_dict["url"] report_hash = url.split("/")[-1] db_report = get_report(db, report_hash) if db_report is None: self.log_info("Report with hash {0} not found.".format(report_hash)) continue db_mantisbug = get_mantis_bug(db, bug_id, db_tracker.id) if db_mantisbug is None: self.log_info("Downloading bug to storage...") db_mantisbug = mbt.download_bug_to_storage(db, bug_id) if db_mantisbug is None: self.log_info("Failed to download bug.") continue db_rm = ( db.session.query(ReportMantis) .filter(ReportMantis.report == db_report) .filter(ReportMantis.mantisbug == db_mantisbug) .first() ) if db_rm is None: db_rm = ReportMantis() db_rm.mantisbug = db_mantisbug db_rm.report = db_report db.session.add(db_rm) db.session.flush() self.log_info("Associated issue #{0} with report #{1}.".format(bug_id, db_report.id)) else: self.log_info("Not a valid ABRT issue.".format(bug_id))
def save_attachment(db, attachment): atype = attachment["type"].lower() if not attachment_type_allowed(atype): raise FafError( "Attachment type '{}' not allowed on this server".format(atype)) report = get_report(db, attachment["bthash"]) if not report: raise FafError("Report for given bthash not found") if atype in ["rhbz", "fedora-bugzilla", "rhel-bugzilla"]: bug_id = int(attachment["data"]) reportbug = (db.session.query( ReportBz).filter((ReportBz.report_id == report.id) & (ReportBz.bzbug_id == bug_id)).first()) if reportbug: log.debug("Skipping existing attachment") return bug = get_bz_bug(db, bug_id) if not bug: if atype in bugtrackers: # download from bugtracker identified by atype tracker = bugtrackers[atype] if not tracker.installed(db): raise FafError("Bugtracker used in this attachment" " is not installed") bug = tracker.download_bug_to_storage(db, bug_id) elif atype == "rhbz": # legacy value # - we need to guess the bugtracker: # either fedora-bugzilla or rhel-bugzilla, # former is more probable for possible_tracker in ["fedora-bugzilla", "rhel-bugzilla"]: if possible_tracker not in bugtrackers: continue tracker = bugtrackers[possible_tracker] if not tracker.installed(db): continue bug = tracker.download_bug_to_storage(db, bug_id) if bug: break if bug: new = ReportBz() new.report = report new.bzbug = bug db.session.add(new) db.session.flush() else: log.error("Failed to fetch bug #{0} from '{1}'".format( bug_id, atype)) elif atype == "centos-mantisbt": bug_id = int(attachment["data"]) reportbug = (db.session.query(ReportMantis).filter( (ReportMantis.report_id == report.id) & (ReportMantis.mantisbug_id == bug_id)).first()) if reportbug: log.debug("Skipping existing attachment") return bug = get_mantis_bug(db, bug_id) if not bug: if atype in bugtrackers: # download from bugtracker identified by atype tracker = bugtrackers[atype] if not tracker.installed(db): raise FafError("Bugtracker used in this attachment" " is not installed") bug = tracker.download_bug_to_storage(db, bug_id) if bug: new = ReportMantis() new.report = report new.mantisbug = bug db.session.add(new) db.session.flush() else: log.error("Failed to fetch bug #{0} from '{1}'".format( bug_id, atype)) elif atype == "comment": comment = ReportComment() comment.report = report comment.text = attachment["data"] comment.saved = datetime.datetime.utcnow() db.session.add(comment) db.session.flush() elif atype == "email": db_contact_email = get_contact_email(db, attachment["data"]) if db_contact_email is None: db_contact_email = ContactEmail() db_contact_email.email_address = attachment["data"] db.session.add(db_contact_email) db_report_contact_email = ReportContactEmail() db_report_contact_email.contact_email = db_contact_email db_report_contact_email.report = report db.session.add(db_report_contact_email) else: db_report_contact_email = \ get_report_contact_email(db, db_contact_email.id, report.id) if db_report_contact_email is None: db_report_contact_email = ReportContactEmail() db_report_contact_email.contact_email = db_contact_email db_report_contact_email.report = report db.session.add(db_report_contact_email) try: db.session.flush() except IntegrityError: raise FafError("Email address already assigned to the report") elif atype == "url": url = attachment["data"] # 0ne URL can be attached to many Reports, but every reports must # have unique url's db_url = (db.session.query(ReportURL).filter( ReportURL.url == url).filter( ReportURL.report_id == report.id).first()) if db_url: log.debug("Skipping existing URL") return db_url = ReportURL() db_url.report = report db_url.url = url db_url.saved = datetime.datetime.utcnow() try: db.session.flush() except IntegrityError: raise FafError("Unable to save URL") else: log.warning("Unknown attachment type")
def save_ureport2(db, ureport, create_component=False, timestamp=None, count=1): """ Save uReport2 """ if timestamp is None: timestamp = datetime.datetime.utcnow() osplugin = systems[ureport["os"]["name"]] problemplugin = problemtypes[ureport["problem"]["type"]] db_osrelease = get_osrelease(db, osplugin.nice_name, ureport["os"]["version"]) if db_osrelease is None: raise FafError( "Operating system '{0} {1}' not found in storage".format( osplugin.nice_name, ureport["os"]["version"])) report_hash = problemplugin.hash_ureport(ureport["problem"]) db_report = get_report(db, report_hash) if db_report is None: component_name = problemplugin.get_component_name(ureport["problem"]) db_component = get_component_by_name(db, component_name, osplugin.nice_name) if db_component is None: if create_component: log.info("Creating an unsupported component '{0}' in " "operating system '{1}'".format( component_name, osplugin.nice_name)) db_component = OpSysComponent() db_component.name = component_name db_component.opsys = db_osrelease.opsys db.session.add(db_component) else: raise FafError("Unknown component '{0}' in operating system " "{1}".format(component_name, osplugin.nice_name)) db_report = Report() db_report.type = problemplugin.name db_report.first_occurrence = timestamp db_report.last_occurrence = timestamp db_report.count = 0 db_report.component = db_component db.session.add(db_report) db_report_hash = ReportHash() db_report_hash.report = db_report db_report_hash.hash = report_hash db.session.add(db_report_hash) if db_report.first_occurrence > timestamp: db_report.first_occurrence = timestamp if db_report.last_occurrence < timestamp: db_report.last_occurrence = timestamp db_reportosrelease = get_reportosrelease(db, db_report, db_osrelease) if db_reportosrelease is None: db_reportosrelease = ReportOpSysRelease() db_reportosrelease.report = db_report db_reportosrelease.opsysrelease = db_osrelease db_reportosrelease.count = 0 db.session.add(db_reportosrelease) db_reportosrelease.count += count db_arch = get_arch_by_name(db, ureport["os"]["architecture"]) if db_arch is None: raise FafError("Architecture '{0}' is not supported".format( ureport["os"]["architecture"])) db_reportarch = get_reportarch(db, db_report, db_arch) if db_reportarch is None: db_reportarch = ReportArch() db_reportarch.report = db_report db_reportarch.arch = db_arch db_reportarch.count = 0 db.session.add(db_reportarch) db_reportarch.count += count reason = ureport["reason"].encode("utf-8") db_reportreason = get_reportreason(db, db_report, reason) if db_reportreason is None: db_reportreason = ReportReason() db_reportreason.report = db_report db_reportreason.reason = reason db_reportreason.count = 0 db.session.add(db_reportreason) db_reportreason.count += count day = timestamp.date() db_daily = get_history_day(db, db_report, db_osrelease, day) if db_daily is None: db_daily = ReportHistoryDaily() db_daily.report = db_report db_daily.opsysrelease = db_osrelease db_daily.day = day db_daily.count = 0 db_daily.unique = 0 db.session.add(db_daily) if "serial" in ureport["problem"] and ureport["problem"]["serial"] == 1: db_daily.unique += 1 db_daily.count += count week = day - datetime.timedelta(days=day.weekday()) db_weekly = get_history_week(db, db_report, db_osrelease, week) if db_weekly is None: db_weekly = ReportHistoryWeekly() db_weekly.report = db_report db_weekly.opsysrelease = db_osrelease db_weekly.week = week db_weekly.count = 0 db_weekly.unique = 0 db.session.add(db_weekly) if "serial" in ureport["problem"] and ureport["problem"]["serial"] == 1: db_weekly.unique += 1 db_weekly.count += count month = day.replace(day=1) db_monthly = get_history_month(db, db_report, db_osrelease, month) if db_monthly is None: db_monthly = ReportHistoryMonthly() db_monthly.report = db_report db_monthly.opsysrelease = db_osrelease db_monthly.month = month db_monthly.count = 0 db_monthly.unique = 0 db.session.add(db_monthly) if "serial" in ureport["problem"] and ureport["problem"]["serial"] == 1: db_monthly.unique += 1 db_monthly.count += count osplugin.save_ureport(db, db_report, ureport["os"], ureport["packages"], count=count) problemplugin.save_ureport(db, db_report, ureport["problem"], count=count) # Update count as last, so that handlers listening to its "set" event have # as much information as possible db_report.count += count db.session.flush() problemplugin.save_ureport_post_flush()
def run(self, cmdline, db): if cmdline.problemtype is None or len(cmdline.problemtype) < 1: ptypes = list(problemtypes.keys()) else: ptypes = [] for ptype in cmdline.problemtype: if ptype not in problemtypes: self.log_warn("Problem type '{0}' is not supported" .format(ptype)) continue ptypes.append(ptype) if not ptypes: self.log_info("Nothing to do") return 0 i = 0 for ptype in ptypes: i += 1 problemtype = problemtypes[ptype] self.log_info("[{0} / {1}] Processing problem type '{2}'" .format(i, len(ptypes), problemtype.nice_name)) db_reports = get_reports_by_type(db, ptype) j = 0 for db_report in db_reports: j += 1 self.log_info(" [{0} / {1}] Processing report #{2}" .format(j, len(db_reports), db_report.id)) hashes = set() k = 0 for db_backtrace in db_report.backtraces: k += 1 self.log_debug(" [{0} / {1}] Processing backtrace #{2}" .format(k, len(db_report.backtraces), db_backtrace.id)) try: component = db_report.component.name include_offset = ptype.lower() == "python" bthash = self._hash_backtrace(db_backtrace, hashbase=[component], offset=include_offset) self.log_debug(" {0}".format(bthash)) db_dup = get_report(db, bthash) if db_dup is None: self.log_info(" Adding hash '{0}'" .format(bthash)) if not bthash in hashes: db_reporthash = ReportHash() db_reporthash.report = db_report db_reporthash.hash = bthash db.session.add(db_reporthash) hashes.add(bthash) elif db_dup == db_report: self.log_debug(" Hash '{0}' already assigned" .format(bthash)) else: self.log_warn((" Conflict! Skipping hash '{0}'" " (report #{1})").format(bthash, db_dup.id)) except FafError as ex: self.log_warn(" {0}".format(str(ex))) continue db.session.flush()
def save_attachment(db, attachment): atype = attachment["type"].lower() if not attachment_type_allowed(atype): raise FafError("Attachment type '{}' not allowed on this server" .format(atype)) report = get_report(db, attachment["bthash"]) if not report: raise FafError("Report for given bthash not found") if atype in ["rhbz", "fedora-bugzilla", "rhel-bugzilla"]: bug_id = int(attachment["data"]) reportbug = (db.session.query(ReportBz) .filter( (ReportBz.report_id == report.id) & (ReportBz.bzbug_id == bug_id) ) .first()) if reportbug: log.debug("Skipping existing attachment") return bug = get_bz_bug(db, bug_id) if not bug: if atype in bugtrackers: # download from bugtracker identified by atype tracker = bugtrackers[atype] if not tracker.installed(db): raise FafError("Bugtracker used in this attachment" " is not installed") bug = tracker.download_bug_to_storage(db, bug_id) elif atype == "rhbz": # legacy value # - we need to guess the bugtracker: # either fedora-bugzilla or rhel-bugzilla, # former is more probable for possible_tracker in ["fedora-bugzilla", "rhel-bugzilla"]: if possible_tracker not in bugtrackers: continue tracker = bugtrackers[possible_tracker] if not tracker.installed(db): continue bug = tracker.download_bug_to_storage(db, bug_id) if bug: break if bug: new = ReportBz() new.report = report new.bzbug = bug db.session.add(new) db.session.flush() else: log.error("Failed to fetch bug #{0} from '{1}'" .format(bug_id, atype)) elif atype == "centos-mantisbt": bug_id = int(attachment["data"]) reportbug = (db.session.query(ReportMantis) .filter( (ReportMantis.report_id == report.id) & (ReportMantis.mantisbug_id == bug_id)) .first()) if reportbug: log.debug("Skipping existing attachment") return bug = get_mantis_bug(db, bug_id) if not bug: if atype in bugtrackers: # download from bugtracker identified by atype tracker = bugtrackers[atype] if not tracker.installed(db): raise FafError("Bugtracker used in this attachment" " is not installed") bug = tracker.download_bug_to_storage(db, bug_id) if bug: new = ReportMantis() new.report = report new.mantisbug = bug db.session.add(new) db.session.flush() else: log.error("Failed to fetch bug #{0} from '{1}'" .format(bug_id, atype)) elif atype == "comment": comment = ReportComment() comment.report = report comment.text = attachment["data"] comment.saved = datetime.datetime.utcnow() db.session.add(comment) db.session.flush() elif atype == "email": db_contact_email = get_contact_email(db, attachment["data"]) if db_contact_email is None: db_contact_email = ContactEmail() db_contact_email.email_address = attachment["data"] db.session.add(db_contact_email) db_report_contact_email = ReportContactEmail() db_report_contact_email.contact_email = db_contact_email db_report_contact_email.report = report db.session.add(db_report_contact_email) else: db_report_contact_email = \ get_report_contact_email(db, db_contact_email.id, report.id) if db_report_contact_email is None: db_report_contact_email = ReportContactEmail() db_report_contact_email.contact_email = db_contact_email db_report_contact_email.report = report db.session.add(db_report_contact_email) try: db.session.flush() except IntegrityError: raise FafError("Email address already assigned to the report") elif atype == "url": url = attachment["data"] # 0ne URL can be attached to many Reports, but every reports must # have unique url's db_url = (db.session.query(ReportURL) .filter(ReportURL.url == url) .filter(ReportURL.report_id == report.id) .first()) if db_url: log.debug("Skipping existing URL") return db_url = ReportURL() db_url.report = report db_url.url = url db_url.saved = datetime.datetime.utcnow() try: db.session.flush() except IntegrityError: raise FafError("Unable to save URL") else: log.warning("Unknown attachment type")
def save_ureport2(db, ureport, create_component=False, timestamp=None, count=1): """ Save uReport2 """ if timestamp is None: timestamp = datetime.datetime.utcnow() osplugin = systems[ureport["os"]["name"]] problemplugin = problemtypes[ureport["problem"]["type"]] db_osrelease = get_osrelease(db, osplugin.nice_name, ureport["os"]["version"]) if db_osrelease is None: raise FafError("Operating system '{0} {1}' not found in storage" .format(osplugin.nice_name, ureport["os"]["version"])) report_hash = problemplugin.hash_ureport(ureport["problem"]) db_report = get_report(db, report_hash) if db_report is None: component_name = problemplugin.get_component_name(ureport["problem"]) db_component = get_component_by_name(db, component_name, osplugin.nice_name) if db_component is None: if create_component: log.info("Creating an unsupported component '{0}' in " "operating system '{1}'".format(component_name, osplugin.nice_name)) db_component = OpSysComponent() db_component.name = component_name db_component.opsys = db_osrelease.opsys db.session.add(db_component) else: raise FafError("Unknown component '{0}' in operating system " "{1}".format(component_name, osplugin.nice_name)) db_report = Report() db_report.type = problemplugin.name db_report.first_occurrence = timestamp db_report.last_occurrence = timestamp db_report.count = 0 db_report.component = db_component db.session.add(db_report) db_report_hash = ReportHash() db_report_hash.report = db_report db_report_hash.hash = report_hash db.session.add(db_report_hash) if db_report.first_occurrence > timestamp: db_report.first_occurrence = timestamp if db_report.last_occurrence < timestamp: db_report.last_occurrence = timestamp db_reportosrelease = get_reportosrelease(db, db_report, db_osrelease) if db_reportosrelease is None: db_reportosrelease = ReportOpSysRelease() db_reportosrelease.report = db_report db_reportosrelease.opsysrelease = db_osrelease db_reportosrelease.count = 0 db.session.add(db_reportosrelease) db_reportosrelease.count += count db_arch = get_arch_by_name(db, ureport["os"]["architecture"]) if db_arch is None: raise FafError("Architecture '{0}' is not supported" .format(ureport["os"]["architecture"])) db_reportarch = get_reportarch(db, db_report, db_arch) if db_reportarch is None: db_reportarch = ReportArch() db_reportarch.report = db_report db_reportarch.arch = db_arch db_reportarch.count = 0 db.session.add(db_reportarch) db_reportarch.count += count reason = ureport["reason"].encode("utf-8") db_reportreason = get_reportreason(db, db_report, reason) if db_reportreason is None: db_reportreason = ReportReason() db_reportreason.report = db_report db_reportreason.reason = reason db_reportreason.count = 0 db.session.add(db_reportreason) db_reportreason.count += count day = timestamp.date() db_daily = get_history_day(db, db_report, db_osrelease, day) if db_daily is None: db_daily = ReportHistoryDaily() db_daily.report = db_report db_daily.opsysrelease = db_osrelease db_daily.day = day db_daily.count = 0 db.session.add(db_daily) db_daily.count += count week = day - datetime.timedelta(days=day.weekday()) db_weekly = get_history_week(db, db_report, db_osrelease, week) if db_weekly is None: db_weekly = ReportHistoryWeekly() db_weekly.report = db_report db_weekly.opsysrelease = db_osrelease db_weekly.week = week db_weekly.count = 0 db.session.add(db_weekly) db_weekly.count += count month = day.replace(day=1) db_monthly = get_history_month(db, db_report, db_osrelease, month) if db_monthly is None: db_monthly = ReportHistoryMonthly() db_monthly.report = db_report db_monthly.opsysrelease = db_osrelease db_monthly.month = month db_monthly.count = 0 db.session.add(db_monthly) db_monthly.count += count osplugin.save_ureport(db, db_report, ureport["os"], ureport["packages"], count=count) problemplugin.save_ureport(db, db_report, ureport["problem"], count=count) # Update count as last, so that handlers listening to its "set" event have # as much information as possible db_report.count += count db.session.flush() problemplugin.save_ureport_post_flush()
def run(self, cmdline, db): if cmdline.problemtype is None or len(cmdline.problemtype) < 1: ptypes = list(problemtypes.keys()) else: ptypes = [] for ptype in cmdline.problemtype: if ptype not in problemtypes: self.log_warn( "Problem type '{0}' is not supported".format(ptype)) continue ptypes.append(ptype) if not ptypes: self.log_info("Nothing to do") return 0 i = 0 for ptype in ptypes: i += 1 problemtype = problemtypes[ptype] self.log_info("[{0} / {1}] Processing problem type '{2}'".format( i, len(ptypes), problemtype.nice_name)) db_reports = get_reports_by_type(db, ptype) j = 0 for db_report in db_reports: j += 1 self.log_info(" [{0} / {1}] Processing report #{2}".format( j, len(db_reports), db_report.id)) hashes = set() k = 0 for db_backtrace in db_report.backtraces: k += 1 self.log_debug( " [{0} / {1}] Processing backtrace #{2}".format( k, len(db_report.backtraces), db_backtrace.id)) try: component = db_report.component.name include_offset = ptype.lower() == "python" bthash = self._hash_backtrace(db_backtrace, hashbase=[component], offset=include_offset) self.log_debug(" {0}".format(bthash)) db_dup = get_report(db, bthash) if db_dup is None: self.log_info( " Adding hash '{0}'".format(bthash)) if not bthash in hashes: db_reporthash = ReportHash() db_reporthash.report = db_report db_reporthash.hash = bthash db.session.add(db_reporthash) hashes.add(bthash) elif db_dup == db_report: self.log_debug( " Hash '{0}' already assigned".format( bthash)) else: self.log_warn( (" Conflict! Skipping hash '{0}'" " (report #{1})").format(bthash, db_dup.id)) except FafError as ex: self.log_warn(" {0}".format(str(ex))) continue db.session.flush() return 0