Package portage :: Package elog :: Module mod_mail
[hide private]

Source Code for Module portage.elog.mod_mail

 1  # elog/mod_mail.py - elog dispatch module 
 2  # Copyright 2006-2007 Gentoo Foundation 
 3  # Distributed under the terms of the GNU General Public License v2 
 4  # $Id: mod_mail.py 14384 2009-09-22 21:26:20Z zmedico $ 
 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 # look at the phases listed in our logentries to figure out what action was performed 24 action = _("merged") 25 for phase in logentries: 26 # if we found a *rm phase assume that the package was unmerged 27 if phase in ["postrm", "prerm"]: 28 action = _("unmerged") 29 # if we think that the package was unmerged, make sure there was no unexpected 30 # phase recorded to avoid misinformation 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