diff options
author | Zac Medico <zmedico@gentoo.org> | 2010-09-11 10:53:43 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2010-09-11 10:53:43 -0700 |
commit | 39d7a0741d5573a26cac3f91cc0e59cae97b755b (patch) | |
tree | 0eba09f3ae28381ccdd10fc3d962abfaf881b524 /pym/portage/elog/mod_mail_summary.py | |
parent | 153788f4f04ed70f0f980a785d0153a149624057 (diff) | |
download | portage-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/mod_mail_summary.py')
-rw-r--r-- | pym/portage/elog/mod_mail_summary.py | 22 |
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()) |