def dissociate_bug(report_id): result = (db.session.query(Report, OpSysComponent).join(OpSysComponent).filter( Report.id == report_id).first()) if result is None: abort(404) _, component = result is_maintainer = is_component_maintainer(db, g.user, component) if not is_maintainer: flash("You are not the maintainer of this component.", "danger") return redirect(url_for("reports.item", report_id=report_id)) form = DissociateBzForm(request.form) if request.method == "POST" and form.validate(): reportbug = get_bugtracker_report(db, form.bug_id.data, report_id) if not reportbug: flash("Bug is not associated with the report.", "danger") else: db.session.delete(reportbug) db.session.flush() db.session.commit() flash("Bug was successfully dissociated from the report.", "success") return redirect(url_for("reports.item", report_id=report_id)) if not form.validate(): flash("Failed to validate bug ID.", "danger") return redirect(url_for("reports.item", report_id=report_id))
def associate_bug(report_id): result = (db.session.query(Report, OpSysComponent).join(OpSysComponent).filter( Report.id == report_id).first()) if result is None: abort(404) report, component = result is_maintainer = is_component_maintainer(db, g.user, component) if not is_maintainer: flash("You are not the maintainer of this component.", "danger") return redirect(url_for("reports.item", report_id=report_id)) form = AssociateBzForm(request.form) if request.method == "POST" and form.validate(): bug_id = form.bug_id.data reportbug = (db.session.query( ReportBz).filter((ReportBz.report_id == report.id) & (ReportBz.bzbug_id == bug_id)).first()) if reportbug: flash("Bug already associated.", "danger") else: bug = get_bz_bug(db, bug_id) if not bug: tracker = bugtrackers[form.bugtracker.data] try: bug = tracker.download_bug_to_storage_no_retry(db, bug_id) except Exception as e: flash("Failed to fetch bug. {0}".format(str(e)), "danger") return redirect( url_for("reports.associate_bug", report_id=report_id)) if bug: newReportBz = ReportBz() newReportBz.report = report newReportBz.bzbug = bug db.session.add(newReportBz) db.session.flush() db.session.commit() flash("Bug successfully associated.", "success") return redirect(url_for("reports.item", report_id=report_id)) bthash_url = url_for("reports.bthash_forward", bthash=report.hashes[0].hash, _external=True) new_bug_params = { "component": component.name, "short_desc": "[abrt] [faf] {0}: {1}(): {2} killed by {3}".format( component.name, report.crash_function, ",".join(exe.path for exe in report.executables), report.errname), "comment": "This bug has been created based on an anonymous crash " "report requested by the package maintainer.\n\n" "Report URL: {0}".format(bthash_url), "bug_file_loc": bthash_url } new_bug_urls = [] for rosr in report.opsysreleases: osr = rosr.opsysrelease for bugtracker in bugtrackers: try: params = new_bug_params.copy() if osr.opsys.name.startswith("Red Hat"): params.update(product="{0} {1}".format( osr.opsys.name, osr.version[0]), version=osr.version) else: params.update(product=osr.opsys.name, version=osr.version) new_bug_urls.append( ("{0} {1} in {2}".format(osr.opsys.name, osr.version, bugtracker), "{0}?{1}".format(bugtrackers[bugtracker].new_bug_url, urllib.parse.urlencode(params)))) except: # pylint: disable=bare-except pass return render_template("reports/associate_bug.html", form=form, report=report, new_bug_urls=new_bug_urls)
def item(report_id, want_object=False): result = (db.session.query(Report, OpSysComponent).join(OpSysComponent).filter( Report.id == report_id).first()) if result is None: abort(404) report, component = result executable = (db.session.query(ReportExecutable.path).filter( ReportExecutable.report_id == report_id).first()) if executable: executable = executable[0] else: executable = "unknown" solutions = None if report.max_certainty is not None: osr = get_report_opsysrelease(db=db, report_id=report.id) solutions = [find_solution(report, db=db, osr=osr)] releases = (db.session.query( ReportOpSysRelease, ReportOpSysRelease.count).filter( ReportOpSysRelease.report_id == report_id).order_by( desc(ReportOpSysRelease.count)).all()) arches = (db.session.query( ReportArch, ReportArch.count).filter(ReportArch.report_id == report_id).order_by( desc(ReportArch.count)).all()) modes = (db.session.query( ReportSelinuxMode, ReportSelinuxMode.count).filter( ReportSelinuxMode.report_id == report_id).order_by( desc(ReportSelinuxMode.count)).all()) history_select = lambda table, date, date_range: ( db.session.query(table).filter(table.report_id == report_id).filter( date >= date_range) # Flot is confused if not ordered .order_by(date).all()) MAX_DAYS = 20 # Default set on 20 MAX_WEEK = 20 # Default set on 20 MAX_MONTH = 20 # Default set on 20 today = datetime.date.today() # Show only 20 days daily_history = history_select(ReportHistoryDaily, ReportHistoryDaily.day, (today - timedelta(days=MAX_DAYS))) if not daily_history: for x in range(0, MAX_DAYS): daily_history.append({ 'day': today - timedelta(x), 'count': 0, 'opsysrelease_id': releases[0].ReportOpSysRelease.opsysrelease_id }) elif len(daily_history) < MAX_DAYS: if daily_history[-1].day < (today): daily_history.append({ 'day': today, 'count': 0, 'opsysrelease_id': releases[0].ReportOpSysRelease.opsysrelease_id }) if daily_history[0].day > (today - timedelta(MAX_DAYS)): daily_history.append({ 'day': today - timedelta(MAX_DAYS), 'count': 0, 'opsysrelease_id': releases[0].ReportOpSysRelease.opsysrelease_id }) # Show only 20 weeks last_monday = datetime.datetime.today() - timedelta( datetime.datetime.today().weekday()) weekly_history = history_select( ReportHistoryWeekly, ReportHistoryWeekly.week, (last_monday - timedelta(days=MAX_WEEK * 7))) if not weekly_history: for x in range(0, MAX_WEEK): weekly_history.append({ 'week': last_monday - timedelta(x * 7), 'count': 0, 'opsysrelease_id': releases[0].ReportOpSysRelease.opsysrelease_id }) elif len(weekly_history) < MAX_WEEK: if weekly_history[-1].week < (last_monday.date()): weekly_history.append({ 'week': last_monday, 'count': 0, 'opsysrelease_id': releases[0].ReportOpSysRelease.opsysrelease_id }) if weekly_history[0].week > ( (last_monday - timedelta(7 * MAX_WEEK)).date()): weekly_history.append({ 'week': last_monday - timedelta(7 * MAX_WEEK), 'count': 0, 'opsysrelease_id': releases[0].ReportOpSysRelease.opsysrelease_id }) # Show only 20 months monthly_history = history_select(ReportHistoryMonthly, ReportHistoryMonthly.month, (today - relativedelta(months=MAX_MONTH))) first_day_of_month = lambda t: (datetime.date(t.year, t.month, 1)) fdom = first_day_of_month(datetime.datetime.today()) if not monthly_history: for x in range(0, MAX_MONTH): monthly_history.append({ 'month': fdom - relativedelta(months=x), 'count': 0, 'opsysrelease_id': releases[0].ReportOpSysRelease.opsysrelease_id }) elif len(monthly_history) < MAX_MONTH: if monthly_history[-1].month < (fdom): monthly_history.append({ 'month': fdom, 'count': 0, 'opsysrelease_id': releases[0].ReportOpSysRelease.opsysrelease_id }) if monthly_history[0].month > (fdom - relativedelta(months=MAX_MONTH)): monthly_history.append({ 'month': fdom - relativedelta(months=MAX_MONTH), 'count': 0, 'opsysrelease_id': releases[0].ReportOpSysRelease.opsysrelease_id }) complete_history = history_select( ReportHistoryMonthly, ReportHistoryMonthly.month, (datetime.datetime.strptime('1970-01-01', '%Y-%m-%d'))) unique_ocurrence_os = {} if complete_history: for ch in complete_history: os_name = "{0} {1}".format(ch.opsysrelease.opsys.name, ch.opsysrelease.version) if ch.count is None: ch.count = 0 if ch.unique is None: ch.count = 0 if os_name not in unique_ocurrence_os: unique_ocurrence_os[os_name] = { 'count': ch.count, 'unique': ch.unique } else: unique_ocurrence_os[os_name]['count'] += ch.count unique_ocurrence_os[os_name]['unique'] += ch.unique sorted(unique_ocurrence_os) packages = load_packages(db, report_id) # creates a package_counts list with this structure: # [(package name, count, [(package version, count in the version)])] names = defaultdict(lambda: {"count": 0, "versions": defaultdict(int)}) for pkg in packages: names[pkg.iname]["name"] = pkg.iname names[pkg.iname]["count"] += pkg.count names[pkg.iname]["versions"]["{0}:{1}-{2}".format( pkg.iepoch, pkg.iversion, pkg.irelease)] += pkg.count package_counts = [] for pkg in sorted(names.values(), key=itemgetter("count"), reverse=True): package_counts.append((pkg["name"], pkg["count"], sorted(pkg["versions"].items(), key=itemgetter(1), reverse=True))) try: backtrace = report.backtraces[0].frames except: # pylint: disable=bare-except backtrace = [] fid = 0 for frame in backtrace: fid += 1 frame.nice_order = fid is_maintainer = is_component_maintainer(db, g.user, component) contact_emails = [] if is_maintainer: contact_emails = [ email_address for (email_address, ) in (db.session.query( ContactEmail.email_address).join(ReportContactEmail).filter( ReportContactEmail.report == report)) ] maintainer = (db.session.query(AssociatePeople).join( OpSysComponentAssociate).join(OpSysComponent).filter( OpSysComponent.name == component.name)).first() maintainer_contact = "" if maintainer: maintainer_contact = maintainer.name probably_fixed = (db.session.query( ProblemOpSysRelease, Build).join(Problem).join(Report).join(Build).filter( Report.id == report_id).first()) unpackaged = not (get_crashed_package_for_report(db, report.id) or get_crashed_unknown_package_nevr_for_report( db, report.id)) forward = dict(report=report, executable=executable, probably_fixed=probably_fixed, component=component, releases=metric(releases), arches=metric(arches), modes=metric(modes), daily_history=daily_history, weekly_history=weekly_history, monthly_history=monthly_history, complete_history=complete_history, unique_ocurrence_os=unique_ocurrence_os, crashed_packages=packages, package_counts=package_counts, backtrace=backtrace, contact_emails=contact_emails, unpackaged=unpackaged, solutions=solutions, maintainer_contact=maintainer_contact) forward['error_name'] = report.error_name forward['oops'] = report.oops if want_object: try: cf = component.name if report.backtraces[0].crash_function: cf += " in {0}".format(report.backtraces[0].crash_function) forward['crash_function'] = cf except: # pylint: disable=bare-except forward['crash_function'] = "" if probably_fixed: tmp_dict = probably_fixed.ProblemOpSysRelease.serialize tmp_dict['probable_fix_build'] = probably_fixed.Build.serialize forward['probably_fixed'] = tmp_dict # Avg count occurrence from first to last occurrence forward['avg_count_per_month'] = get_avg_count(report.first_occurrence, report.last_occurrence, report.count) if forward['report'].bugs: forward['bugs'] = [] for bug in forward['report'].bugs: try: forward['bugs'].append(bug.serialize) except: # pylint: disable=bare-except print("Bug serialize failed") return forward if request_wants_json(): return jsonify(forward) forward["is_maintainer"] = is_maintainer forward["extfafs"] = get_external_faf_instances(db) return render_template("reports/item.html", **forward)
def item(report_id, want_object=False) -> Union[Dict[str, Any], Response, str]: result = (db.session.query(Report, OpSysComponent).join(OpSysComponent).filter( Report.id == report_id).first()) if result is None: abort(404) report, component = result executable = (db.session.query(ReportExecutable.path).filter( ReportExecutable.report_id == report_id).first()) if executable: executable = executable[0] else: executable = "unknown" solutions = None if report.max_certainty is not None: osr = get_report_opsysrelease(db=db, report_id=report.id) solutions = [find_solution(report, db=db, osr=osr)] releases = (db.session.query( ReportOpSysRelease, ReportOpSysRelease.count).filter( ReportOpSysRelease.report_id == report_id).order_by( desc(ReportOpSysRelease.count)).all()) arches = (db.session.query( ReportArch, ReportArch.count).filter(ReportArch.report_id == report_id).order_by( desc(ReportArch.count)).all()) modes = (db.session.query( ReportSelinuxMode, ReportSelinuxMode.count).filter( ReportSelinuxMode.report_id == report_id).order_by( desc(ReportSelinuxMode.count)).all()) daily_history = precompute_history(report_id, 'day') weekly_history = precompute_history(report_id, 'week') monthly_history = precompute_history(report_id, 'month') complete_history = (db.session.query(ReportHistoryMonthly).filter( ReportHistoryMonthly.report_id == report_id).all()) unique_ocurrence_os = {} if complete_history: for ch in complete_history: os_name = str(ch.opsysrelease) if ch.count is None: ch.count = 0 if ch.unique is None: ch.count = 0 if os_name not in unique_ocurrence_os: unique_ocurrence_os[os_name] = { 'count': ch.count, 'unique': ch.unique } else: unique_ocurrence_os[os_name]['count'] += ch.count unique_ocurrence_os[os_name]['unique'] += ch.unique packages = load_packages(db, report_id) crashed_versions = {} last_affected_version = "N/A" # creates a package_counts list with this structure: # [(package name, count, [(package version, count in the version)])] names = defaultdict(lambda: {"count": 0, "versions": defaultdict(int)}) for pkg in packages: names[pkg.iname]["name"] = pkg.iname names[pkg.iname]["count"] += pkg.count names[pkg.iname]["versions"]["{0}:{1}-{2}".format( pkg.iepoch, pkg.iversion, pkg.irelease)] += pkg.count if pkg.type == "CRASHED": crashed_versions = names[pkg.iname]["versions"] if crashed_versions: last_affected_version = sorted(crashed_versions.keys())[-1] package_counts = [] for pkg in sorted(names.values(), key=itemgetter("count"), reverse=True): package_counts.append((pkg["name"], pkg["count"], sorted(pkg["versions"].items(), key=itemgetter(1), reverse=True))) try: backtrace = report.backtraces[0].frames except: # pylint: disable=bare-except backtrace = [] fid = 0 for frame in backtrace: fid += 1 frame.nice_order = fid is_maintainer = is_component_maintainer(db, g.user, component) contact_emails = [] if is_maintainer: contact_emails = [ email_address for (email_address, ) in (db.session.query( ContactEmail.email_address).join(ReportContactEmail).filter( ReportContactEmail.report == report)) ] maintainer = (db.session.query(AssociatePeople).join( OpSysComponentAssociate).join(OpSysComponent).filter( OpSysComponent.name == component.name)).first() maintainer_contact = "" if maintainer: maintainer_contact = maintainer.name probably_fixed = (db.session.query( ProblemOpSysRelease, Build).join(Problem).join(Report).join(Build).filter( Report.id == report_id).first()) unpackaged = not (get_crashed_package_for_report(db, report.id) or get_crashed_unknown_package_nevr_for_report( db, report.id)) forward = dict(report=report, executable=executable, probably_fixed=probably_fixed, component=component, releases=metric(releases), arches=metric(arches), modes=metric(modes), daily_history=daily_history, weekly_history=weekly_history, monthly_history=monthly_history, complete_history=complete_history, unique_ocurrence_os=unique_ocurrence_os, crashed_packages=packages, package_counts=package_counts, backtrace=backtrace, contact_emails=contact_emails, unpackaged=unpackaged, solutions=solutions, maintainer_contact=maintainer_contact) forward['error_name'] = report.error_name forward['oops'] = report.oops forward['version'] = last_affected_version if want_object: try: cf = component.name if report.backtraces[0].crash_function: cf += " in {0}".format(report.backtraces[0].crash_function) forward['crash_function'] = cf except: # pylint: disable=bare-except forward['crash_function'] = "" if probably_fixed: tmp_dict = probably_fixed.ProblemOpSysRelease.serialize tmp_dict['probable_fix_build'] = probably_fixed.Build.serialize forward['probably_fixed'] = tmp_dict # Avg count occurrence from first to last occurrence forward['avg_count_per_month'] = get_avg_count(report.first_occurrence, report.last_occurrence, report.count) if forward['report'].bugs: forward['bugs'] = [] for bug in forward['report'].bugs: try: forward['bugs'].append(bug.serialize) except: # pylint: disable=bare-except print("Bug serialize failed") return forward if request_wants_json(): return Response(response=json.dumps(forward, cls=WebfafJSONEncoder), status=200, mimetype="application/json") forward["is_maintainer"] = is_maintainer forward["extfafs"] = get_external_faf_instances(db) return render_template("reports/item.html", **forward)
def associate_bug(report_id): result = (db.session.query(Report, OpSysComponent) .join(OpSysComponent) .filter(Report.id == report_id) .first()) if result is None: abort(404) report, component = result is_maintainer = is_component_maintainer(db, g.user, component) if not is_maintainer: flash("You are not the maintainer of this component.", "danger") return redirect(url_for("reports.item", report_id=report_id)) form = AssociateBzForm(request.form) if request.method == "POST" and form.validate(): bug_id = form.bug_id.data reportbug = (db.session.query(ReportBz) .filter( (ReportBz.report_id == report.id) & (ReportBz.bzbug_id == bug_id)) .first()) if reportbug: flash("Bug already associated.", "danger") else: bug = get_bz_bug(db, bug_id) if not bug: tracker = bugtrackers[form.bugtracker.data] try: bug = tracker.download_bug_to_storage_no_retry(db, bug_id) except Exception as e: #pylint: disable=broad-except flash("Failed to fetch bug. {0}".format(str(e)), "danger") return redirect(url_for("reports.associate_bug", report_id=report_id)) if bug: newReportBz = ReportBz() newReportBz.report = report newReportBz.bzbug = bug db.session.add(newReportBz) db.session.flush() db.session.commit() flash("Bug successfully associated.", "success") return redirect(url_for("reports.item", report_id=report_id)) bthash_url = url_for("reports.bthash_forward", bthash=report.hashes[0].hash, _external=True) new_bug_params = { "component": component.name, "short_desc": "[abrt] [faf] {0}: {1}(): {2} killed by {3}" .format(component.name, report.crash_function, ",".join(exe.path for exe in report.executables), report.errname ), "comment": "This bug has been created based on an anonymous crash " "report requested by the package maintainer.\n\n" "Report URL: {0}" .format(bthash_url), "bug_file_loc": bthash_url } new_bug_urls = [] for rosr in report.opsysreleases: osr = rosr.opsysrelease for bugtracker in bugtrackers: try: params = new_bug_params.copy() if osr.opsys.name.startswith("Red Hat"): params.update(product="{0} {1}".format(osr.opsys.name, osr.version[0]), version=osr.version) else: params.update(product=osr.opsys.name, version=osr.version) new_bug_urls.append( ("{0} {1} in {2}".format(osr.opsys.name, osr.version, bugtracker), "{0}?{1}".format( bugtrackers[bugtracker].new_bug_url, urllib.parse.urlencode(params)) ) ) except: # pylint: disable=bare-except pass return render_template("reports/associate_bug.html", form=form, report=report, new_bug_urls=new_bug_urls)
def item(report_id, want_object=False): result = (db.session.query(Report, OpSysComponent) .join(OpSysComponent) .filter(Report.id == report_id) .first()) if result is None: abort(404) report, component = result executable = (db.session.query(ReportExecutable.path) .filter(ReportExecutable.report_id == report_id) .first()) if executable: executable = executable[0] else: executable = "unknown" solutions = None if report.max_certainty is not None: osr = get_report_opsysrelease(db=db, report_id=report.id) solutions = [find_solution(report, db=db, osr=osr)] releases = (db.session.query(ReportOpSysRelease, ReportOpSysRelease.count) .filter(ReportOpSysRelease.report_id == report_id) .order_by(desc(ReportOpSysRelease.count)) .all()) arches = (db.session.query(ReportArch, ReportArch.count) .filter(ReportArch.report_id == report_id) .order_by(desc(ReportArch.count)) .all()) modes = (db.session.query(ReportSelinuxMode, ReportSelinuxMode.count) .filter(ReportSelinuxMode.report_id == report_id) .order_by(desc(ReportSelinuxMode.count)) .all()) history_select = lambda table, date, date_range: (db.session.query(table). filter(table.report_id == report_id) .filter(date >= date_range) # Flot is confused if not ordered .order_by(date) .all()) MAX_DAYS = 20 # Default set on 20 MAX_WEEK = 20 # Default set on 20 MAX_MONTH = 20 # Default set on 20 today = datetime.date.today() # Show only 20 days daily_history = history_select(ReportHistoryDaily, ReportHistoryDaily.day, (today - timedelta(days=MAX_DAYS))) if not daily_history: for x in range(0, MAX_DAYS): daily_history.append({'day': today - timedelta(x), 'count': 0, 'opsysrelease_id': releases[0].ReportOpSysRelease.opsysrelease_id}) elif len(daily_history) < MAX_DAYS: if daily_history[-1].day < (today): daily_history.append({'day': today, 'count': 0, 'opsysrelease_id': releases[0].ReportOpSysRelease.opsysrelease_id }) if daily_history[0].day > (today - timedelta(MAX_DAYS)): daily_history.append({'day': today - timedelta(MAX_DAYS), 'count': 0, 'opsysrelease_id': releases[0].ReportOpSysRelease.opsysrelease_id }) # Show only 20 weeks last_monday = datetime.datetime.today() - timedelta(datetime.datetime.today().weekday()) weekly_history = history_select(ReportHistoryWeekly, ReportHistoryWeekly.week, (last_monday - timedelta(days=MAX_WEEK*7))) if not weekly_history: for x in range(0, MAX_WEEK): weekly_history.append({'week': last_monday - timedelta(x*7), 'count': 0, 'opsysrelease_id': releases[0].ReportOpSysRelease.opsysrelease_id}) elif len(weekly_history) < MAX_WEEK: if weekly_history[-1].week < (last_monday.date()): weekly_history.append({'week': last_monday, 'count': 0, 'opsysrelease_id': releases[0].ReportOpSysRelease.opsysrelease_id}) if weekly_history[0].week > ((last_monday - timedelta(7*MAX_WEEK)).date()): weekly_history.append({'week': last_monday - timedelta(7*MAX_WEEK), 'count': 0, 'opsysrelease_id': releases[0].ReportOpSysRelease.opsysrelease_id}) # Show only 20 months monthly_history = history_select(ReportHistoryMonthly, ReportHistoryMonthly.month, (today - relativedelta(months=MAX_MONTH))) first_day_of_month = lambda t: (datetime.date(t.year, t.month, 1)) fdom = first_day_of_month(datetime.datetime.today()) if not monthly_history: for x in range(0, MAX_MONTH): monthly_history.append({'month': fdom - relativedelta(months=x), 'count': 0, 'opsysrelease_id': releases[0].ReportOpSysRelease.opsysrelease_id}) elif len(monthly_history) < MAX_MONTH: if monthly_history[-1].month < (fdom): monthly_history.append({'month': fdom, 'count': 0, 'opsysrelease_id': releases[0].ReportOpSysRelease.opsysrelease_id}) if monthly_history[0].month > (fdom - relativedelta(months=MAX_MONTH)): monthly_history.append({'month': fdom - relativedelta(months=MAX_MONTH), 'count': 0, 'opsysrelease_id': releases[0].ReportOpSysRelease.opsysrelease_id}) complete_history = history_select(ReportHistoryMonthly, ReportHistoryMonthly.month, (datetime.datetime.strptime('1970-01-01', '%Y-%m-%d'))) unique_ocurrence_os = {} if complete_history: for ch in complete_history: os_name = "{0} {1}".format(ch.opsysrelease.opsys.name, ch.opsysrelease.version) if ch.count is None: ch.count = 0 if ch.unique is None: ch.count = 0 if os_name not in unique_ocurrence_os: unique_ocurrence_os[os_name] = {'count': ch.count, 'unique': ch.unique} else: unique_ocurrence_os[os_name]['count'] += ch.count unique_ocurrence_os[os_name]['unique'] += ch.unique sorted(unique_ocurrence_os) packages = load_packages(db, report_id) crashed_versions = [] last_affected_version = "N/A" # creates a package_counts list with this structure: # [(package name, count, [(package version, count in the version)])] names = defaultdict(lambda: {"count": 0, "versions": defaultdict(int)}) for pkg in packages: names[pkg.iname]["name"] = pkg.iname names[pkg.iname]["count"] += pkg.count names[pkg.iname]["versions"]["{0}:{1}-{2}" .format(pkg.iepoch, pkg.iversion, pkg.irelease)] += pkg.count if pkg.type == "CRASHED": crashed_versions = names[pkg.iname]["versions"] if crashed_versions: last_affected_version = sorted(crashed_versions.keys())[-1] package_counts = [] for pkg in sorted(names.values(), key=itemgetter("count"), reverse=True): package_counts.append(( pkg["name"], pkg["count"], sorted(pkg["versions"].items(), key=itemgetter(1), reverse=True))) try: backtrace = report.backtraces[0].frames except: # pylint: disable=bare-except backtrace = [] fid = 0 for frame in backtrace: fid += 1 frame.nice_order = fid is_maintainer = is_component_maintainer(db, g.user, component) contact_emails = [] if is_maintainer: contact_emails = [email_address for (email_address, ) in (db.session.query(ContactEmail.email_address) .join(ReportContactEmail) .filter(ReportContactEmail.report == report))] maintainer = (db.session.query(AssociatePeople) .join(OpSysComponentAssociate) .join(OpSysComponent) .filter(OpSysComponent.name == component.name)).first() maintainer_contact = "" if maintainer: maintainer_contact = maintainer.name probably_fixed = (db.session.query(ProblemOpSysRelease, Build) .join(Problem) .join(Report) .join(Build) .filter(Report.id == report_id) .first()) unpackaged = not (get_crashed_package_for_report(db, report.id) or get_crashed_unknown_package_nevr_for_report(db, report.id)) forward = dict(report=report, executable=executable, probably_fixed=probably_fixed, component=component, releases=metric(releases), arches=metric(arches), modes=metric(modes), daily_history=daily_history, weekly_history=weekly_history, monthly_history=monthly_history, complete_history=complete_history, unique_ocurrence_os=unique_ocurrence_os, crashed_packages=packages, package_counts=package_counts, backtrace=backtrace, contact_emails=contact_emails, unpackaged=unpackaged, solutions=solutions, maintainer_contact=maintainer_contact) forward['error_name'] = report.error_name forward['oops'] = report.oops forward['version'] = last_affected_version if want_object: try: cf = component.name if report.backtraces[0].crash_function: cf += " in {0}".format(report.backtraces[0].crash_function) forward['crash_function'] = cf except: # pylint: disable=bare-except forward['crash_function'] = "" if probably_fixed: tmp_dict = probably_fixed.ProblemOpSysRelease.serialize tmp_dict['probable_fix_build'] = probably_fixed.Build.serialize forward['probably_fixed'] = tmp_dict # Avg count occurrence from first to last occurrence forward['avg_count_per_month'] = get_avg_count(report.first_occurrence, report.last_occurrence, report.count) if forward['report'].bugs: forward['bugs'] = [] for bug in forward['report'].bugs: try: forward['bugs'].append(bug.serialize) except: # pylint: disable=bare-except print("Bug serialize failed") return forward if request_wants_json(): return jsonify(forward) forward["is_maintainer"] = is_maintainer forward["extfafs"] = get_external_faf_instances(db) return render_template("reports/item.html", **forward)