diff options
Diffstat (limited to 'pym/elog_modules')
-rw-r--r-- | pym/elog_modules/mod_echo.py | 19 | ||||
-rw-r--r-- | pym/elog_modules/mod_mail_summary.py | 26 |
2 files changed, 32 insertions, 13 deletions
diff --git a/pym/elog_modules/mod_echo.py b/pym/elog_modules/mod_echo.py index 55d33bb1f..b798fb94b 100644 --- a/pym/elog_modules/mod_echo.py +++ b/pym/elog_modules/mod_echo.py @@ -8,18 +8,27 @@ from portage_const import EBUILD_PHASES _items = {} def process(mysettings, key, logentries, fulltext): - _items[key] = logentries + global _items + config_root = mysettings["PORTAGE_CONFIGROOT"] + mysettings, items = _items.setdefault(config_root, (mysettings, {})) + items[key] = logentries -def finalize(mysettings): +def finalize(): + global _items + for mysettings, items in _items.itervalues(): + _finalize(mysettings, items) + _items.clear() + +def _finalize(mysettings, items): printer = EOutput() - for key in _items: + for key, logentries in items.iteritems(): print printer.einfo("Messages for package %s:" % key) print for phase in EBUILD_PHASES: - if not phase in _items[key]: + if phase not in logentries: continue - for msgtype, msgcontent in _items[key][phase]: + for msgtype, msgcontent in logentries[phase]: fmap = {"INFO": printer.einfo, "WARN": printer.ewarn, "ERROR": printer.eerror, 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 |