aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2010-09-11 10:53:43 -0700
committerZac Medico <zmedico@gentoo.org>2010-09-11 10:53:43 -0700
commit39d7a0741d5573a26cac3f91cc0e59cae97b755b (patch)
tree0eba09f3ae28381ccdd10fc3d962abfaf881b524 /pym/portage/elog
parentFix typo in comment. (diff)
downloadportage-39d7a0741d5573a26cac3f91cc0e59cae97b755b.tar.gz
portage-39d7a0741d5573a26cac3f91cc0e59cae97b755b.tar.bz2
portage-39d7a0741d5573a26cac3f91cc0e59cae97b755b.zip
Make the mail_summary elog module copy needed variables from the config
instance, since we don't need to hold a reference for the whole thing. This also makes it possible to rely on per-package variable settings that may have come from /etc/portage/package.env, since we'll be isolated from any future mutations of mysettings.
Diffstat (limited to 'pym/portage/elog')
-rw-r--r--pym/portage/elog/mod_mail_summary.py22
1 files changed, 19 insertions, 3 deletions
diff --git a/pym/portage/elog/mod_mail_summary.py b/pym/portage/elog/mod_mail_summary.py
index 1997ddd48..0bd67f22b 100644
--- a/pym/portage/elog/mod_mail_summary.py
+++ b/pym/portage/elog/mod_mail_summary.py
@@ -13,6 +13,8 @@ from portage import _unicode_decode
import socket
import time
+_config_keys = ('PORTAGE_ELOG_MAILURI', 'PORTAGE_ELOG_MAILFROM',
+ 'PORTAGE_ELOG_MAILSUBJECT',)
_items = {}
def process(mysettings, key, logentries, fulltext):
global _items
@@ -22,7 +24,21 @@ def process(mysettings, key, logentries, fulltext):
header = _(">>> Messages generated for package %(pkg)s by process %(pid)d on %(time)s:\n\n") % \
{"pkg": key, "pid": os.getpid(), "time": time_str}
config_root = mysettings["PORTAGE_CONFIGROOT"]
- mysettings, items = _items.setdefault(config_root, (mysettings, {}))
+
+ # Copy needed variables from the config instance,
+ # since we don't need to hold a reference for the
+ # whole thing. This also makes it possible to
+ # rely on per-package variable settings that may
+ # have come from /etc/portage/package.env, since
+ # we'll be isolated from any future mutations of
+ # mysettings.
+ config_dict = {}
+ for k in _config_keys:
+ v = mysettings.get(k)
+ if v is not None:
+ config_dict[k] = v
+
+ config_dict, items = _items.setdefault(config_root, (config_dict, {}))
items[key] = header + fulltext
def finalize():
@@ -43,9 +59,9 @@ def _finalize(mysettings, items):
else:
myrecipient = "root@localhost"
- myfrom = mysettings["PORTAGE_ELOG_MAILFROM"]
+ myfrom = mysettings.get("PORTAGE_ELOG_MAILFROM", "")
myfrom = myfrom.replace("${HOST}", socket.getfqdn())
- mysubject = mysettings["PORTAGE_ELOG_MAILSUBJECT"]
+ mysubject = mysettings.get("PORTAGE_ELOG_MAILSUBJECT", "")
mysubject = mysubject.replace("${PACKAGE}", count)
mysubject = mysubject.replace("${HOST}", socket.getfqdn())