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:
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.
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
}
def zephyr_escape(m):
+ m = str(m)
m = re.sub('@', '@@', m)
m = re.sub('}', '@(})', m)
return m
'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'
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',