URL: https://svn.lrde.epita.fr/svn/lrde-tools/trunk/buildbot Git branch: master (HEAD: 4ffdab6)
ChangeLog: 2007-11-25 Benoit Sigoure tsuna@lrde.epita.fr
Add a Maildir parser for the commit hook messages of spot. * masters/spot_master.cfg (MyMaildirSource): New class. Use it. Send build failures to <login>@src.lip6.fr.
--- masters/ChangeLog | 7 ++++ masters/spot_master.cfg | 71 +++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 75 insertions(+), 3 deletions(-)
diff --git a/masters/ChangeLog b/masters/ChangeLog index a0ce577..6903e26 100644 --- a/masters/ChangeLog +++ b/masters/ChangeLog @@ -1,3 +1,10 @@ +2007-11-25 Benoit Sigoure tsuna@lrde.epita.fr + + Add a Maildir parser for the commit hook messages of spot. + * masters/spot_master.cfg (MyMaildirSource): New class. + Use it. + Send build failures to <login>@src.lip6.fr. + 2007-11-21 Benoit Sigoure tsuna@lrde.epita.fr
Add a buildfarm for Spot. diff --git a/masters/spot_master.cfg b/masters/spot_master.cfg index 5754f0a..103175a 100644 --- a/masters/spot_master.cfg +++ b/masters/spot_master.cfg @@ -32,8 +32,73 @@ c['slavePortnum'] = 9945 # source code changes. Any class which implements IChangeSource can be added # to this list: there are several in buildbot/changes/*.py to choose from.
-import buildbot.changes.pb -c['change_source'] = [buildbot.changes.pb.PBChangeSource()] +from buildbot.changes.mail import MaildirSource +from buildbot.changes import changes +from email.Utils import parseaddr +from email.Iterators import body_line_iterator +import re +from time import mktime, strptime +from twisted.python import log +# Forked from FCMaildirSource +class MyMaildirSource(MaildirSource): + name = "MyMaildirSource" + + def parse(self, m, prefix=None): + """Parse mail sent by spot CVS commit hook""" + + log.msg('MyMaildirSource.parse') + files = None + comments = None + lines = list(body_line_iterator(m)) + who = None + # Who, when + while lines: + line = lines.pop(0) + if line.startswith("Changes by:"): + line = line.rstrip("\n") + log.msg('Got a commit mail: ' + line) + r = re.compile(r'Changes by:\s*([^<]+) <([^>]*)>\s*([\d\s/:]*)') + m = r.match(line) + name = m.group(1) + addr = m.group(2) + # Take the login from the email eg: foo@bar.com -> foo + who = addr[0:addr.find('@')] + when = mktime(strptime(m.group(3), "%y/%m/%d %H:%M:%S")) + break + while lines: + line = lines.pop(0) + if line == "Modified files:\n": + files = [] + break + # What changed + while lines: + line = lines.pop(0) + if line == "\n": + break + file = line.rstrip("\n") + files.append(file) + # Why + while lines: + line = lines.pop(0) + if line == "Log message:\n": + comments = "" + break + # message is terminated by "Patches:" or "Index:..." (patch) + while lines: + line = lines.pop(0) + if line.startswith("Patches:") or line.startswith("Index: "): + comments = comments.rstrip() + "\n" + break + comments += line + # The mail was just some noise, it doesn't come from the + # commit hook or is malformated. + if who is None or files is None or comments is None: + log.msg("mail seems incomplete") + return None + return changes.Change(who, files, comments, when=when) + +import os +c['change_source'] = MyMaildirSource(os.path.expanduser("~/Maildir"))
####### SCHEDULERS # http://buildbot.sourceforge.net/manual-0.7.4.html#Listing-Change-Sources-and... @@ -173,7 +238,7 @@ c['status'].append(html.WebStatus(http_port="tcp:8045:interface=127.0.0.1",
from buildbot.status import mail c['status'].append(mail.MailNotifier(fromaddr="buildbot@lrde.epita.fr", - lookup="lrde.epita.fr", + lookup="src.lip6.fr", mode="problem", sendToInterestedUsers=True)) #