Beispiel #1
0
def finalize_comment(bzquery, first, stats, info, changeset, bugid):
    """Finalize the comment to put in the bug report"""
    comment = bzquery["comment"][0]
    env = Environment(loader=FileSystemLoader("templates"))
    template = env.get_template("bug.txt")
    channel = info["channel"]
    url = Mercurial.get_repo_url(channel)
    url = "{}/rev?node={}".format(url, changeset)
    if channel == "nightly":
        version = "nightly {}".format(utils.get_major(info["version"]))
    else:
        version = info["version"]

    comment = template.render(
        socorro_comment=comment,
        count=stats["count"],
        installs=stats["installs"],
        version=version,
        buildid=info["buildid"],
        bugid=bugid,
        changeset_url=url,
        first=first,
    )
    comment = comment.replace("\\n", "\n")
    bzquery["comment"] = comment
    bzurl = "https://bugzilla.mozilla.org/enter_bug.cgi"
    return bzurl + "?" + urlencode(bzquery, True)
Beispiel #2
0
def finalize_comment(bzquery, first, stats, info, changeset, bugid):
    """Finalize the comment to put in the bug report"""
    comment = bzquery['comment'][0]
    env = Environment(loader=FileSystemLoader('templates'))
    template = env.get_template('bug.txt')
    channel = info['channel']
    url = Mercurial.get_repo_url(channel)
    url = '{}/rev?node={}'.format(url, changeset)
    if channel == 'nightly':
        version = 'nightly {}'.format(utils.get_major(info['version']))
    else:
        version = info['version']

    comment = template.render(socorro_comment=comment,
                              count=stats['count'],
                              installs=stats['installs'],
                              version=version,
                              buildid=info['buildid'],
                              bugid=bugid,
                              changeset_url=url,
                              first=first)
    comment = comment.replace('\\n', '\n')
    bzquery['comment'] = comment
    bzurl = 'https://bugzilla.mozilla.org/enter_bug.cgi'
    return bzurl + '?' + urlencode(bzquery, True)
Beispiel #3
0
    def get_by_uuid(uuid):
        uuid_info = UUID.get_bid_chan_by_uuid(uuid)
        if not uuid_info:
            return {}, {}

        uuidid = uuid_info["id"]
        repo_url = Mercurial.get_repo_url(uuid_info["channel"])
        is_java = uuid_info["java"]

        iframes = (db.session.query(
            CrashStack.stackpos,
            Node.node,
            Node.backedout,
            Node.pushdate,
            Node.bug,
            Node.id,
            Score.score,
        ).select_from(CrashStack).join(Score).join(Changeset).join(Node))
        iframes = iframes.filter(CrashStack.uuidid == uuidid,
                                 CrashStack.java.is_(is_java)).order_by(
                                     CrashStack.stackpos, Node.id.desc())
        frames = (db.session.query(CrashStack).filter(
            CrashStack.uuidid == uuidid,
            CrashStack.java.is_(is_java)).order_by(CrashStack.stackpos))
        stack = []
        res = {"frames": stack}
        for frame in frames:
            url, filename = utils.get_file_url(repo_url, frame.filename,
                                               frame.node, frame.line,
                                               frame.original)
            stack.append({
                "stackpos": frame.stackpos,
                "filename": filename,
                "function": frame.function,
                "changesets": OrderedDict(),
                "line": frame.line,
                "node": frame.node,
                "original": frame.original,
                "internal": frame.internal,
                "url": url,
            })

        for stackpos, node, bout, pdate, bugid, nodeid, score in iframes:
            stack[stackpos]["changesets"][node] = {
                "score": score,
                "backedout": bout,
                "pushdate": pdate,
                "bugid": bugid,
            }

        return res, uuid_info
Beispiel #4
0
def get_pushlog(startdate, enddate, channel='nightly'):
    """Get the pushlog from hg.mozilla.org"""
    # Get the pushes where startdate <= pushdate <= enddate
    # pushlog uses strict inequality, it's why we add +/- 1 second
    fmt = '%Y-%m-%d %H:%M:%S'
    startdate -= relativedelta(seconds=1)
    startdate = startdate.strftime(fmt)
    enddate += relativedelta(seconds=1)
    enddate = enddate.strftime(fmt)
    url = '{}/json-pushes'.format(Mercurial.get_repo_url(channel))
    r = requests.get(
        url,
        params={'startdate': startdate, 'enddate': enddate, 'version': 2, 'full': 1},
    )
    return r.json()
Beispiel #5
0
def pushlog_for_revs(startrev,
                     endrev,
                     channel='nightly',
                     file_filter=utils.is_interesting_file):
    """Get the pushlog from startrev to endrev"""
    # startrev is not include in the pushlog
    url = '{}/json-pushes'.format(Mercurial.get_repo_url(channel))
    r = requests.get(url,
                     params={
                         'fromchange': startrev,
                         'tochange': endrev,
                         'version': 2,
                         'full': 1
                     })
    return collect(r.json(), file_filter)
Beispiel #6
0
def diff():
    filename = request.args.get('filename', '')
    line = request.args.get('line', '')
    style = request.args.get('style', 'file')
    node = request.args.get('node', '')
    changeset = request.args.get('changeset', '')
    channel = request.args.get('channel', '')
    repo_url = Mercurial.get_repo_url(channel)
    annotate_url = '{}/{}/{}/{}#l{}'.format(repo_url, style, node, filename,
                                            line)
    diff_url = '{}/diff/{}/{}'.format(repo_url, changeset, filename)

    return render_template('diff.html',
                           changeset=changeset,
                           filename=filename,
                           annotate_url=annotate_url,
                           diff_url=diff_url)
Beispiel #7
0
def pushlog_for_revs(startrev,
                     endrev,
                     channel="nightly",
                     file_filter=utils.is_interesting_file):
    """Get the pushlog from startrev to endrev"""
    # startrev is not include in the pushlog
    url = "{}/json-pushes".format(Mercurial.get_repo_url(channel))
    r = requests.get(
        url,
        params={
            "fromchange": startrev,
            "tochange": endrev,
            "version": 2,
            "full": 1
        },
    )
    return collect(r.json(), file_filter)
Beispiel #8
0
    def get_by_uuid(uuid):
        uuid_info = UUID.get_bid_chan_by_uuid(uuid)
        if not uuid_info:
            return {}, {}

        uuidid = uuid_info['id']
        repo_url = Mercurial.get_repo_url(uuid_info['channel'])
        is_java = uuid_info['java']

        iframes = db.session.query(CrashStack.stackpos,
                                   Node.node,
                                   Node.backedout,
                                   Node.pushdate,
                                   Node.bug,
                                   Node.id,
                                   Score.score).join(Score).join(Changeset).join(Node)
        iframes = iframes.filter(CrashStack.uuidid == uuidid,
                                 CrashStack.java.is_(is_java)).order_by(CrashStack.stackpos, Node.id.desc())
        frames = db.session.query(CrashStack).filter(CrashStack.uuidid == uuidid,
                                                     CrashStack.java.is_(is_java)).order_by(CrashStack.stackpos)
        stack = []
        res = {'frames': stack}
        for frame in frames:
            url, filename = utils.get_file_url(repo_url,
                                               frame.filename,
                                               frame.node,
                                               frame.line,
                                               frame.original)
            stack.append({'stackpos': frame.stackpos,
                          'filename': filename,
                          'function': frame.function,
                          'changesets': OrderedDict(),
                          'line': frame.line,
                          'node': frame.node,
                          'original': frame.original,
                          'internal': frame.internal,
                          'url': url})

        for stackpos, node, bout, pdate, bugid, nodeid, score, in iframes:
            stack[stackpos]['changesets'][node] = {'score': score,
                                                   'backedout': bout,
                                                   'pushdate': pdate,
                                                   'bugid': bugid}

        return res, uuid_info
Beispiel #9
0
def crashstack():
    uuid = request.args.get('uuid', '')
    stack, uuid_info = models.CrashStack.get_by_uuid(uuid)
    if uuid_info:
        channel = uuid_info['channel']
        repo_url = Mercurial.get_repo_url(channel)
        sgn_url = utils.make_url_for_signature(
            uuid_info['signature'], uuid_info['buildid'],
            utils.get_buildid(uuid_info['buildid']), channel,
            uuid_info['product'])
        return render_template('crashstack.html',
                               uuid_info=uuid_info,
                               stack=stack,
                               colors=utils.get_colors(),
                               enumerate=enumerate,
                               repo_url=repo_url,
                               channel=channel,
                               sgn_url=sgn_url)
    abort(404)
Beispiel #10
0
def diff():
    filename = request.args.get("filename", "")
    line = request.args.get("line", "")
    style = request.args.get("style", "file")
    node = request.args.get("node", "")
    changeset = request.args.get("changeset", "")
    channel = request.args.get("channel", "")
    repo_url = Mercurial.get_repo_url(channel)
    annotate_url = "{}/{}/{}/{}#l{}".format(repo_url, style, node, filename,
                                            line)
    diff_url = "{}/diff/{}/{}".format(repo_url, changeset, filename)

    return render_template(
        "diff.html",
        changeset=changeset,
        filename=filename,
        annotate_url=annotate_url,
        diff_url=diff_url,
    )
Beispiel #11
0
def get_pushlog(startdate, enddate, channel="nightly"):
    """Get the pushlog from hg.mozilla.org"""
    # Get the pushes where startdate <= pushdate <= enddate
    # pushlog uses strict inequality, it's why we add +/- 1 second
    fmt = "%Y-%m-%d %H:%M:%S"
    startdate -= relativedelta(seconds=1)
    startdate = startdate.strftime(fmt)
    enddate += relativedelta(seconds=1)
    enddate = enddate.strftime(fmt)
    url = "{}/json-pushes".format(Mercurial.get_repo_url(channel))
    r = requests.get(
        url,
        params={
            "startdate": startdate,
            "enddate": enddate,
            "version": 2,
            "full": 1
        },
    )
    return r.json()
Beispiel #12
0
def get_pushlog(startdate, enddate, channel='nightly'):
    """Get the pushlog from hg.mozilla.org"""
    # Get the pushes where startdate <= pushdate <= enddate
    # pushlog uses strict inequality, it's why we add +/- 1 second
    fmt = '%Y-%m-%d %H:%M:%S'
    startdate -= relativedelta(seconds=1)
    startdate = startdate.strftime(fmt)
    enddate += relativedelta(seconds=1)
    enddate = enddate.strftime(fmt)
    url = '{}/json-pushes'.format(Mercurial.get_repo_url(channel))
    r = requests.get(
        url,
        params={
            'startdate': startdate,
            'enddate': enddate,
            'version': 2,
            'full': 1
        },
    )
    return r.json()
Beispiel #13
0
def reformat_java_stacktrace(
    st,
    channel,
    buildid,
    get_full_path=models.File.get_full_path,
    get_changeset=tools.get_changeset,
):
    if not st:
        return ""

    node = get_changeset(buildid, channel, "FennecAndroid")
    if not node:
        return html.escape(st)

    res = ""
    repo_url = Mercurial.get_repo_url(channel)
    lines = list(st.split("\n"))
    N = len(lines)
    for i in range(N):
        line = lines[i]
        m = JAVA_PAT1.match(line.strip())
        line = html.escape(line)
        added = False
        if m:
            path, filename, linenumber = m.groups()
            if path.startswith("org.mozilla."):
                base_path, _ = parse_path(path)
                repo_filename = base_path + "/" + filename
                repo_filename = get_full_path(repo_filename)
                r = '(<a href="{}/annotate/{}/{}#l{}">{}:{}</a>)'
                r = r.format(
                    repo_url, node, repo_filename, linenumber, filename, linenumber
                )
                res += JAVA_PAT3.sub(r, line)
                added = True
        if not added:
            res += line
        if i < N - 1:
            res += "\n"

    return res
Beispiel #14
0
def crashstack():
    uuid = request.args.get("uuid", "")
    stack, uuid_info = models.CrashStack.get_by_uuid(uuid)
    if uuid_info:
        channel = uuid_info["channel"]
        repo_url = Mercurial.get_repo_url(channel)
        sgn_url = utils.make_url_for_signature(
            uuid_info["signature"],
            uuid_info["buildid"],
            utils.get_buildid(uuid_info["buildid"]),
            channel,
            uuid_info["product"],
        )
        return render_template(
            "crashstack.html",
            uuid_info=uuid_info,
            stack=stack,
            colors=utils.get_colors(),
            enumerate=enumerate,
            repo_url=repo_url,
            channel=channel,
            sgn_url=sgn_url,
        )
    abort(404)
Beispiel #15
0
def pushlog_for_revs_url(startrev, endrev, channel):
    """Get the pushlog url from startrev to endrev"""
    return "{}/pushloghtml?fromchange={}&tochange={}".format(
        Mercurial.get_repo_url(channel), startrev, endrev)
Beispiel #16
0
 def __init__(self):
     super().__init__()
     self.bugs = []
     self.repourl = Mercurial.get_repo_url("nightly")