[Buildbot-devel] customMesg for mail.MailNotifier ...
Charles Lepple
clepple at gmail.com
Wed Aug 26 11:19:25 UTC 2009
On Aug 26, 2009, at 3:34 AM, Kiffin Gish wrote:
> 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.
I tried something similar in the interpreter before posting, but I
bungled it while converting it back to your example.
What about this?
if attrs['buildProperties']:
text.append('Build properties : %s' % '\n'.join(['%s:%s' % \
(key, val) for key,val in attrs['buildProperties'].items()]))
More information about the devel
mailing list