[Buildbot-devel] customMesg for mail.MailNotifier ...

Charles Lepple clepple at gmail.com
Tue Aug 25 23:52:01 UTC 2009


On Tue, Aug 25, 2009 at 2:26 PM, Kiffin Gish<kiffin.gish at planet.nl> wrote:
> I've defined my own user-defined custom message function for email
> notifications. It works pretty well, except for attrs['changes'] and
> attrs['reason'] whose formatting could be better.
>
> I'm pretty much a newbie when it comes to programming in Python, so I
> was hoping someone could help me. The best I can do is the following:
>
> if attrs['buildProperties']:
>        text.append('Build properties : %s' % attrs['buildProperties'])
>
> which gives me this:
>
> Build properties : {'scheduler': 'code_changed', 'buildername':
> 'builder-cmt-web-make', 'got_revision': '1360', 'warnings-count': 0,
> 'buildnumber': 9, 'slavename': 'slave-dev1', 'branch': None, 'os':
> 'Linux', 'revision': '1360'}

It looks like this code is using the built-in string conversion on
attrs['buildProperties'].

You could do something like this:

if attrs['buildProperties']:
        text.append('Build properties : %s' % ['\n'.join('%s:%s' %
(key, val)) for key,val in attrs['buildProperties']])


> and:
>
> if len(attrs['changes']):
>    text.append('Changes : %s' % [c.asText() for c in attrs['changes']])
>
> which gives me this:
>
> Changes : [u'File: file1\nAt: Tue 25 Aug 2009 17:27:01\nChanged By:
> kgish\nComments: Comments for file1\n\n\n', u'File: file2\nAt: Tue 25
> Aug 2009 17:27:01\nChanged By: kgish\nComments: Comments for file2\n\n
> \n', u'File: file3\nAt: Tue 25 Aug 2009 17:27:02\nChanged By: bartx
> \nComments: Comments for file3\n\n\n']
>
> How can I extract the separate items and make it look something like
> this?

Same idea here - your list comprehension (the "[c... for c in
attrs...]" part) is returning a list.

-- 
- Charles Lepple




More information about the devel mailing list