From 39d7a0741d5573a26cac3f91cc0e59cae97b755b Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sat, 11 Sep 2010 10:53:43 -0700 Subject: 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. --- pym/portage/elog/mod_mail_summary.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'pym/portage/elog') 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()) -- cgit v1.2.3-1-g7c22