diff options
author | Richard Purdie <richard@openedhand.com> | 2008-06-17 11:46:50 +0000 |
---|---|---|
committer | Richard Purdie <richard@openedhand.com> | 2008-06-17 11:46:50 +0000 |
commit | a833e9a35f51d656443c9493df288b708dc7da6d (patch) | |
tree | 3825d6c1e023d4a5d977653f02bfb4f71d7da961 /meta/classes/poky-autobuild-notifier.bbclass | |
parent | afe20e409112a244212c2820c8bb2960085c9c25 (diff) | |
download | poky-a833e9a35f51d656443c9493df288b708dc7da6d.tar.gz |
classes: Add poky-autobuild-notifier class
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@4679 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'meta/classes/poky-autobuild-notifier.bbclass')
-rw-r--r-- | meta/classes/poky-autobuild-notifier.bbclass | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/meta/classes/poky-autobuild-notifier.bbclass b/meta/classes/poky-autobuild-notifier.bbclass new file mode 100644 index 0000000000..ef353e0f19 --- /dev/null +++ b/meta/classes/poky-autobuild-notifier.bbclass | |||
@@ -0,0 +1,61 @@ | |||
1 | # | ||
2 | # Copyright Openedhand Ltd 2008 | ||
3 | # Author: Richard Purdie | ||
4 | # | ||
5 | |||
6 | """ | ||
7 | Designed for use with the Poky autobuilder only and provides custom hooks for | ||
8 | certain specific events. | ||
9 | """ | ||
10 | |||
11 | def do_autobuilder_failure_report(event): | ||
12 | from bb.event import getName | ||
13 | from bb import data, mkdirhier, build | ||
14 | import os, glob | ||
15 | |||
16 | if data.getVar('PN', event.data, True) != "clutter": | ||
17 | return | ||
18 | |||
19 | import smtplib | ||
20 | import email.Message | ||
21 | |||
22 | version = data.expand("${PN}: ${PV}-${PR}", event.data) | ||
23 | |||
24 | message = email.Message.Message() | ||
25 | message["To"] = "richard@o-hand.com, ebassi@o-hand.com, pippin@o-hand.com" | ||
26 | message["From"] = "Poky Autobuilder Failure <poky@o-hand.com>" | ||
27 | message["Subject"] = "Poky Autobuild Failure Report - " + version | ||
28 | |||
29 | mesg = "Poky Build Failure for:\n\n" | ||
30 | |||
31 | for var in ["DISTRO", "MACHINE", "PN", "PV", "PR"]: | ||
32 | mesg += var + ": " + data.getVar(var, event.data, True) + "\n" | ||
33 | |||
34 | mesg += "\nLog of the failure follows:\n\n" | ||
35 | |||
36 | log_file = glob.glob("%s/log.%s.*" % (data.getVar('T', event.data, True), event.task)) | ||
37 | if len(log_file) != 0: | ||
38 | mesg += "".join(open(log_file[0], 'r').readlines()) | ||
39 | |||
40 | message.set_payload(mesg) | ||
41 | |||
42 | mailServer = smtplib.SMTP("pug.o-hand.com") | ||
43 | mailServer.sendmail(message["From"], message["To"], message.as_string()) | ||
44 | mailServer.quit() | ||
45 | |||
46 | # we want to be an event handler | ||
47 | addhandler poky_autobuilder_notifier_eventhandler | ||
48 | python poky_autobuilder_notifier_eventhandler() { | ||
49 | from bb import note, error, data | ||
50 | from bb.event import NotHandled, getName | ||
51 | |||
52 | if e.data is None: | ||
53 | return NotHandled | ||
54 | |||
55 | name = getName(e) | ||
56 | |||
57 | if name == "TaskFailed": | ||
58 | do_autobuilder_failure_report(e) | ||
59 | |||
60 | return NotHandled | ||
61 | } | ||