- 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
emergelog("notitles" not in settings.features,
" *** exiting successfully.")
+ # Dump the mod_echo output now so that our other notifications are shown
+ # last.
+ from elog_modules import mod_echo
+ mod_echo.finalize()
+
if "noinfo" not in settings.features:
chk_updated_info_files(target_root, infodirs, info_mtimes, retval)
_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,
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"
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
signal.alarm(0)
if hasattr(m, "finalize") and not m.finalize in _elog_atexit_handlers:
_elog_atexit_handlers.append(m.finalize)
- atexit_register(m.finalize, mysettings)
+ atexit_register(m.finalize)
except (ImportError, AttributeError), e:
writemsg("!!! Error while importing logging modules " + \
"while loading \"mod_%s\":\n" % str(s))