X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-dev.git/blobdiff_plain/04075cce54b210a67f89b6f10754a2437bdb168b..58fdf80b634ee62e377cc28e5607525b57bcbef0:/build-hooks/post-build?ds=inline diff --git a/build-hooks/post-build b/build-hooks/post-build index b304900..8dd8eb4 100755 --- a/build-hooks/post-build +++ b/build-hooks/post-build @@ -62,7 +62,8 @@ from email.mime import text from invirt import common, database, builder from invirt.config import structs as config -def build_completion_msg(succeeded, values, verbose=True, success=lambda x: x, failure=lambda x: x): +def build_completion_msg(succeeded, values, verbose=True, success=lambda x: x, failure=lambda x: x, + escape=lambda x: x): """Format a message reporting the results of a build""" values = dict(values) if not verbose and values['traceback'] is not None: @@ -75,13 +76,14 @@ def build_completion_msg(succeeded, values, verbose=True, success=lambda x: x, f break values['traceback'] = truncated + for key in ['package', 'version', 'pocket', 'principal', 'inserted_at', 'short_commit']: + values[key] = escape(values[key]) + if succeeded: values['result'] = success(values['result']) msg = """Build of %(package)s %(version)s in %(pocket)s %(result)s. - -Branch %(pocket)s has been advanced to %(short_commit)s. - -(Build %(build_id)s was submitted by %(principal)s at %(inserted_at)s.)""" % values +Job submitted by %(principal)s at %(inserted_at)s. +Branch %(pocket)s has been advanced to %(short_commit)s.""" % values else: values['result'] = failure(values['result']) msg = """Build of %(package)s version %(version)s in %(pocket)s %(result)s while %(failed_stage)s. @@ -89,17 +91,21 @@ Job submitted by %(principal)s at %(inserted_at)s. Error: %(traceback)s""" % values return msg -def submit_completion_msg(succeeded, values, verbose=True, success=lambda x: x, failure=lambda x: x): +def submit_completion_msg(succeeded, values, verbose=True, success=lambda x: x, failure=lambda x: x, + escape=lambda x: x): values = dict(values) if succeeded: values['result'] = success(values['result']) else: values['result'] = failure(values['result']) + for key in ['commit', 'pocket', 'principal']: + values[key] = escape(values[key]) msg = """Submission of %(commit)s to be built in %(pocket)s %(result)s. Build submitted by %(principal)s.""" % values return msg -def repo_creation_msg(succeeded, values, verbose=True, success=lambda x: x, failure=lambda x: x): +def repo_creation_msg(succeeded, values, verbose=True, success=lambda x: x, failure=lambda x: x, + escape=lambda x: x): values = dict(values) assert succeeded msg = '%(principal)s just created a new repository, %(category)s/%(name)s.git' % values @@ -131,6 +137,7 @@ message_generators = { } def zephyr_escape(m): + m = str(m) m = re.sub('@', '@@', m) m = re.sub('}', '@(})', m) return m @@ -182,8 +189,8 @@ def main(): 'short_commit' : short_commit, 'traceback' : build.traceback, 'version' : build.version, - 'default_instance' : 'build_%(build_id)s', - 'default_subject' : 'XVM build %(result)s: %(package)s %(version)s in %(pocket)s'} + 'default_instance' : 'b%(build_id)s', + 'default_subject' : 'Build %(build_id)d %(result)s: %(package)s %(version)s in %(pocket)s'} if build.succeeded: assert prog == POST_BUILD values['result'] = 'succeeded' @@ -231,7 +238,8 @@ def main(): else: make_msg = message_generators[ZEPHYR][prog] msg = '@{%s}' % make_msg(succeeded, values, verbose=False, - success=zephyr_success, failure=zephyr_failure) + success=zephyr_success, failure=zephyr_failure, + escape=zephyr_escape) instance = zephyr_config.get('instance', values['default_instance']) % values zsig = zephyr_config.get('zsig', 'XVM Buildbot') % values common.captureOutput(['zwrite', '-c', klass, '-i', instance, '-s',