Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: FIREFOX_6_0b3_…
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 120 lines (102 sloc) 4.199 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
import re
import os.path

def buildTryChangeMessage(change, packageDir):
    got_revision = revision = change.revision[:12]
    who = change.who
    packageDir = packageDir % locals()
    msgdict = {"type": "plain"}
    msgdict['subject'] = "Try submission %(revision)s" % locals()
    msgdict['headers'] = {"In-Reply-To": "<try-%(revision)s>" % locals(),
                          "References": "<try-%(revision)s>" % locals(),
                          }
    msgdict["body"] = """\
Thanks for your try submission (http://hg.mozilla.org/try/pushloghtml?changeset=%(revision)s). It's the best!

Watch http://tbpl.mozilla.org/?tree=Try&rev=%(revision)s for your results to come in.

Builds and logs will be available at %(packageDir)s.

This directory won't be created until the first builds are uploaded, so please be patient.
""" % locals()

    return msgdict

def buildTryCompleteMessage(attrs, packageDir, tinderboxTree):
    platform = ''
    task = ''
    got_revision = ''
    who = ''
    builder = attrs['builderName']

    try:
        got_revision = attrs['buildProperties']['got_revision']
    except KeyError:
        try:
            got_revision = attrs['buildProperties']['revision']
        except KeyError:
            got_revision = 'revision-not-set'
    try:
        who = attrs['buildProperties']['who']
    except KeyError:
        who = 'who-not-set'

    if 'Linux x86-64' in builder:
        platform = 'linux64'
    elif 'Linux' in builder:
        platform = 'linux'
    elif 'OS X 10.6' in builder:
        platform = 'mac64'
    elif 'OS X 10.5' in builder:
        platform = 'mac'
    elif 'WINNT 5.2' in builder:
        platform = 'win32'
    elif 'WINNT 6.1' in builder:
        platform = 'win64'
    elif 'Maemo' in builder:
        platform = 'maemo'

    if 'test' in builder:
        task = 'test'
    elif 'talos' in builder:
        task = 'talos'
    else:
        task = 'build'

    url = packageDir % locals()

    if attrs['result'] == 'success':
        text = """\
Your Try Server %(task)s (%(got_revision)s) was successfully completed on \
%(platform)s on builder: %(builder)s.\n\n""" % locals()
    elif attrs['result'] == 'warnings':
        text = """\
Your Try Server %(task)s (%(got_revision)s) completed with warnings on \
%(platform)s on builder: %(builder)s.\n\n""" % locals()
    elif attrs['result'] == 'exception':
        text = """\
Your Try Server %(task)s (%(got_revision)s) hit an exception on \
%(platform)s on builder: %(builder)s.\n\n""" % locals()
    elif attrs['result'] == 'failure':
        text = """\
Your Try Server %(task)s (%(got_revision)s) failed to complete on \
%(platform)s on builder: %(builder)s.\n\n""" % locals()
    else:
        text = """\
Unknown issues arose during %(task)s (%(got_revision)s) on \
%(platform)s on builder: %(builder)s. Check with RelEng if you have questions.\n\n""" % locals()

    if attrs['result'] in ('success', 'warnings') and packageDir and 'who-not-set' not in who:
        text += "It should be available for download at %(url)s\n\n" % locals()
    if attrs['result'] in ('failure', 'exception') and 'who-not-set' not in who:
        text += "While some of the build steps haven't succeeded, your build package might have been \
successfully created and could be available for download at %(url)s\n\n" % locals()

    if task == 'test':
        text += "Summary of test results:\n"
        for log in attrs['logs']:
            if 'summary' not in log[0]:
                continue
            summary = ''.join(log[2]).replace('TinderboxPrint: ', '')
            summary = summary.replace('<br/>', ': ')
            text += '%s\n' % summary
        text += '\n'

    elif task == 'talos':
        text += "Summary of talos results:\n"
        for log in attrs['logs']:
            if 'summary' not in log[0]:
                continue
            for line in log[2]:
                test = re.search("(\w+): ([0-9.:]+)", line)
                if test:
                    text += "%s\n" % (test.group(0))
        text += '\n'

    text += """Visit http://tbpl.mozilla.org/?tree=%(tinderboxTree)s&rev=%(revision)s to view the full logs.""" % locals()

    return (text, 'plain')

Something went wrong with that request. Please try again.