summaryrefslogtreecommitdiffstats
path: root/pym/elog_modules/mod_mail_summary.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-06-22 23:35:43 +0000
committerZac Medico <zmedico@gentoo.org>2007-06-22 23:35:43 +0000
commita1dd09f64ccefbff495d0607aeec5422f32b93fb (patch)
tree62c9a69da0de2e3937f974da75c0eb438bf0c0b2 /pym/elog_modules/mod_mail_summary.py
parent8e074705115908deec094527f4c60a4c31941827 (diff)
downloadportage-a1dd09f64ccefbff495d0607aeec5422f32b93fb.tar.gz
portage-a1dd09f64ccefbff495d0607aeec5422f32b93fb.tar.bz2
portage-a1dd09f64ccefbff495d0607aeec5422f32b93fb.zip
- Make elog finalize() handling safe for PORTAGE_CONFIGROOT. (trunk r6955)
- Dump mod_echo elog output inside post_emerge(), just before the other notifications that happen at exit. (trunk r6953) svn path=/main/branches/2.1.2/; revision=6958
Diffstat (limited to 'pym/elog_modules/mod_mail_summary.py')
-rw-r--r--pym/elog_modules/mod_mail_summary.py26
1 files changed, 18 insertions, 8 deletions
diff --git a/pym/elog_modules/mod_mail_summary.py b/pym/elog_modules/mod_mail_summary.py
index 783d73196..22ec0ff0c 100644
--- a/pym/elog_modules/mod_mail_summary.py
+++ b/pym/elog_modules/mod_mail_summary.py
@@ -7,15 +7,24 @@ import portage_mail, socket, os, time
from email.MIMEText import MIMEText as TextMessage
_items = {}
-def process(mysettings, cpv, logentries, fulltext):
+def process(mysettings, key, logentries, fulltext):
+ global _items
header = ">>> Messages generated for package %s by process %d on %s:\n\n" % \
- (cpv, os.getpid(), time.strftime("%Y%m%d-%H%M%S", time.gmtime(time.time())))
- _items[cpv] = header + fulltext
+ (key, os.getpid(), time.strftime("%Y%m%d-%H%M%S", time.gmtime(time.time())))
+ config_root = mysettings["PORTAGE_CONFIGROOT"]
+ mysettings, items = _items.setdefault(config_root, (mysettings, {}))
+ items[key] = header + fulltext
-def finalize(mysettings):
- if len(_items) == 0:
+def finalize():
+ global _items
+ for mysettings, items in _items.itervalues():
+ _finalize(mysettings, items)
+ _items.clear()
+
+def _finalize(mysettings, items):
+ if len(items) == 0:
return
- elif len(_items) == 1:
+ elif len(items) == 1:
count = "one package"
else:
count = "multiple packages"
@@ -31,10 +40,11 @@ def finalize(mysettings):
mybody = "elog messages for the following packages generated by " + \
"process %d on host %s:\n" % (os.getpid(), socket.getfqdn())
- for cpv in _items:
+ for cpv in items:
mybody += "- %s\n" % cpv
- mymessage = portage_mail.create_message(myfrom, myrecipient, mysubject, mybody, attachments=_items.values())
+ mymessage = portage_mail.create_message(myfrom, myrecipient, mysubject,
+ mybody, attachments=items.values())
portage_mail.send_mail(mysettings, mymessage)
return