1
2
3
4
5
6 import portage.mail, socket
7 from portage.exception import PortageException
8 from portage.localization import _
9 from portage.util import writemsg
10
11 -def process(mysettings, key, logentries, fulltext):
12 if "PORTAGE_ELOG_MAILURI" in mysettings:
13 myrecipient = mysettings["PORTAGE_ELOG_MAILURI"].split()[0]
14 else:
15 myrecipient = "root@localhost"
16
17 myfrom = mysettings["PORTAGE_ELOG_MAILFROM"]
18 myfrom = myfrom.replace("${HOST}", socket.getfqdn())
19 mysubject = mysettings["PORTAGE_ELOG_MAILSUBJECT"]
20 mysubject = mysubject.replace("${PACKAGE}", key)
21 mysubject = mysubject.replace("${HOST}", socket.getfqdn())
22
23
24 action = _("merged")
25 for phase in logentries:
26
27 if phase in ["postrm", "prerm"]:
28 action = _("unmerged")
29
30
31 if action == _("unmerged"):
32 for phase in logentries:
33 if phase not in ["postrm", "prerm", "other"]:
34 action = _("unknown")
35
36 mysubject = mysubject.replace("${ACTION}", action)
37
38 mymessage = portage.mail.create_message(myfrom, myrecipient, mysubject, fulltext)
39 try:
40 portage.mail.send_mail(mysettings, mymessage)
41 except PortageException as e:
42 writemsg("%s\n" % str(e), noiselevel=-1)
43
44 return
45