summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-06-22 23:11:38 +0000
committerZac Medico <zmedico@gentoo.org>2007-06-22 23:11:38 +0000
commita382630c4c4414597190da450970f4885a632b62 (patch)
tree13ff560b1a9ec85d49b940668bf5bdd5b1aaf403
parentf2beaa1b01fbfc9ad8eea94df22ca92947446d01 (diff)
downloadportage-a382630c4c4414597190da450970f4885a632b62.tar.gz
portage-a382630c4c4414597190da450970f4885a632b62.tar.bz2
portage-a382630c4c4414597190da450970f4885a632b62.zip
Make elog finalize() handling safe for PORTAGE_CONFIGROOT.
svn path=/main/trunk/; revision=6955
-rw-r--r--pym/emerge/__init__.py7
-rw-r--r--pym/portage/elog/__init__.py7
-rw-r--r--pym/portage/elog/mod_echo.py19
-rw-r--r--pym/portage/elog/mod_mail_summary.py22
4 files changed, 33 insertions, 22 deletions
diff --git a/pym/emerge/__init__.py b/pym/emerge/__init__.py
index 6d8da7c2d..17ff8d58d 100644
--- a/pym/emerge/__init__.py
+++ b/pym/emerge/__init__.py
@@ -3870,12 +3870,9 @@ def post_emerge(trees, mtimedb, retval):
" *** exiting successfully.")
# Dump the mod_echo output now so that our other notifications are shown
- # last. FIXME: handle finalize for multiple config instances
- # (PORTAGE_CONFIGROOT support).
+ # last.
from portage.elog import mod_echo
- if mod_echo._items:
- mod_echo.finalize(settings)
- mod_echo._items.clear()
+ mod_echo.finalize()
if "noinfo" not in settings.features:
chk_updated_info_files(target_root, infodirs, info_mtimes, retval)
diff --git a/pym/portage/elog/__init__.py b/pym/portage/elog/__init__.py
index 1cf4dd8b8..cbe9f47fa 100644
--- a/pym/portage/elog/__init__.py
+++ b/pym/portage/elog/__init__.py
@@ -95,14 +95,9 @@ def elog_process(cpv, mysettings):
m.process(mysettings, str(key), mod_logentries, mod_fulllog)
finally:
signal.alarm(0)
- # FIXME: when installing to more than one $ROOT, the finalizer
- # will only be registered with a config instance from one of
- # the roots (randomly). With PORTAGE_CONFIGROOT, the config
- # instances can have completely different settings, so
- # logs can end up in the wrong PORT_LOGDIR for example.
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))
diff --git a/pym/portage/elog/mod_echo.py b/pym/portage/elog/mod_echo.py
index 6dcc65233..308c8efcc 100644
--- a/pym/portage/elog/mod_echo.py
+++ b/pym/portage/elog/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/portage/elog/mod_mail_summary.py b/pym/portage/elog/mod_mail_summary.py
index 0a39b17b1..884df40c8 100644
--- a/pym/portage/elog/mod_mail_summary.py
+++ b/pym/portage/elog/mod_mail_summary.py
@@ -8,14 +8,23 @@ from email.MIMEText import MIMEText as TextMessage
_items = {}
def process(mysettings, key, logentries, fulltext):
+ global _items
header = ">>> Messages generated for package %s by process %d on %s:\n\n" % \
(key, os.getpid(), time.strftime("%Y%m%d-%H%M%S", time.gmtime(time.time())))
- _items[key] = header + fulltext
+ 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 key in _items:
+ for key in items:
mybody += "- %s\n" % key
- 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