Exemple #1
0
def format_issue(kind_id):
    kind = CrashKind.get(id=kind_id)
    crashes = Crash.select().where(Crash.kind_id == kind_id)
    reporter_table = ""
    additional = []
    for c in crashes:
        reporter_table += reporter_row.format(**c._data)
        if c.description:
            additional.append(c.description)
    v = {
        "stack": crashes[0].stack,
        "type": kind.type,
        "exc_string": crashes[0].exc_string,
        "reporter_table": reporter_table,
        "user_count": len(crashes)
    }
    report = template.format(**v)
    if additional:
        for a in additional:
            report += "\n> ".join([""] + a.splitlines())
            report += "\n\n---\n\n"
    else:
        report += no_info
    title = kind.type + ": " + crashes[0].exc_string
    return title, report
Exemple #2
0
def format_issue(kind_id):
    kind = CrashKind.get(id=kind_id)
    crashes = Crash.select().where(Crash.kind_id == kind_id)
    reporter_table = ""
    additional = []
    for c in crashes:
        stack_url = config.get("external_url") + "/crash/" + str(c.id)
        reporter_table += reporter_row.format(
            stack_url=stack_url, **model_to_dict(c)).replace("\n", " ") + "\n"
        if c.description:
            additional.append(c.description)
    v = {
        "stack": crashes[0].stack,
        "type": kind.type,
        "exc_string": crashes[0].exc_string,
        "reporter_table": reporter_table,
        "user_count": len(crashes),
        "app_name": config.get("app_name")
    }
    report = template.format(**v)
    if additional:
        for a in additional:
            report += "\n> ".join([""] + a.splitlines())
            report += "\n\n---\n\n"
    else:
        report += no_info
    title = kind.type + ": " + crashes[0].exc_string
    if len(title) > 400:
        title = title[:400] + "..."
    return title, report
Exemple #3
0
def store_crash():
    if not check_rate_limit(request):
        return "Thanks for reporting this issue!"
    crash = json.loads(request.data)
    # Give Windows paths forward slashes
    crash["id"]["file"] = crash["id"]["file"].replace("\\", "/")
    # We only care about the file name
    crash["id"]["file"] = os.path.split(crash["id"]["file"])[1]
    kind, created = CrashKind.get_or_create(**crash["id"])
    del crash["id"]
    crash["kind_id"] = kind.id
    Crash.create(**crash)
    title, body = issues.format_issue(kind.id)
    if created:
        issue = github.report_issue(title, body)
        kind.github_id = issue
        kind.save()
    else:
        github.update_issue(kind.github_id, title, body)
    url = "https://github.com/{}/issues/{}".format(config.get("github_project"), kind.github_id)
    return """
    Thanks for reporting this issue! You can track further progress on <a href="{url}">GitHub</a>.
    """.format(url=url)
Exemple #4
0
def store_crash(request):
    if not check_rate_limit(request):
        return {
            "text": "Thanks for reporting this issue!",
            "status": "skip",
            "location": None
        }
    crash = json.loads(request.data)
    # Give Windows paths forward slashes
    crash["id"]["file"] = crash["id"]["file"].replace("\\", "/")
    # We only care about the file name
    crash["id"]["file"] = os.path.split(crash["id"]["file"])[1]
    kind, created = CrashKind.get_or_create(**crash["id"])
    del crash["id"]
    crash["kind_id"] = kind.id
    Crash.create(**crash)
    title, body = issues.format_issue(kind.id)
    if kind.github_id < 0:
        issue = github.report_issue(title, body)
        kind.github_id = issue
        kind.save()
    else:
        github.update_issue(kind.github_id, body)
        if github.issue_is_closed(kind.github_id):
            body = issues.format_reopen_comment(
                kind.id, github.issue_closed_by(kind.github_id))
            if body:
                github.respond(kind.github_id, body)
    url = "https://github.com/{}/issues/{}".format(
        config.get("github_project"), kind.github_id)
    return {
        "text":
        "Thanks for reporting this issue! You can track further progress on GitHub.",
        "status": "reported",
        "location": url
    }
Exemple #5
0
def format_reopen_comment(kind_id, closed_by):
    kind = CrashKind.get(id=kind_id)
    crashes = Crash.select().where(Crash.kind_id == kind_id)
    if len(crashes) < 2:
        return None
    crashes, new_crash = crashes[:-1], crashes[-1:][0]
    min_version = None
    for c in crashes:
        if not min_version or LooseVersion(min_version) < LooseVersion(c.app_version):
            min_version = c.app_version
    if not LooseVersion(min_version) < LooseVersion(new_crash.app_version):
        return None
    v = {
        "greeting": get_greeting(),
        "user_closed": closed_by.login,
        "app_name": config.get("app_name"),
        "version": new_crash.app_version,
        "min_version": min_version,
        "stack": new_crash.stack,
        "type": kind.type,
        "exc_string": new_crash.exc_string
    }
    return template_reopen.format(**v)
Exemple #6
0
def show_crash(id):
    crash = Crash.get(Crash.id == id)
    return "<pre>{}</pre>".format(escape(crash.stack))