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

Kiffin Gish kiffin.gish at planet.nl
Wed Aug 26 07:34:42 UTC 2009


On Tue, 2009-08-25 at 19:52 -0400, Charles Lepple wrote:
> 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']])
> 

Unfortunately I get an 'exceptions.KeyError: 0' error. I believe that
attrs['buildProperties'] is a class instance and the key,value call will
not work.

Other ideas?

> 
> > 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.

Yeps, this one works!

> 
-- 
Kiffin Gish <Kiffin.Gish at planet.nl>
Gouda, The Netherlands






More information about the devel mailing list