From 0e5042832d9497b586c4fa3dadf845519db2bd78 Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Wed, 13 Feb 2019 09:20:00 +0100 Subject: [PATCH] split admin_emails option in koji.add_mail_logger If there are multiple e-mailes separated by comma of space, they should be split for correct usage of smtplib.sendmail. Fixes: https://pagure.io/koji/issue/1240 --- builder/kojid | 3 ++- koji/__init__.py | 11 ++++++++++- vm/kojivmd | 3 ++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/builder/kojid b/builder/kojid index fc7e0e02..7504da9f 100755 --- a/builder/kojid +++ b/builder/kojid @@ -6120,7 +6120,8 @@ def get_options(): parser.add_option("--maxjobs", type='int', help="Specify maxjobs") parser.add_option("--minspace", type='int', help="Specify minspace") parser.add_option("--sleeptime", type='int', help="Specify the polling interval") - parser.add_option("--admin-emails", help="Address(es) to send error notices to") + parser.add_option("--admin-emails", type='str', action="store", metavar="EMAILS", + help="Comma-separated addresses to send error notices to.") parser.add_option("--topdir", help="Specify topdir") parser.add_option("--topurl", help="Specify topurl") parser.add_option("--workdir", help="Specify workdir") diff --git a/koji/__init__.py b/koji/__init__.py index d0f9a6ce..d0abfb07 100644 --- a/koji/__init__.py +++ b/koji/__init__.py @@ -3446,11 +3446,20 @@ def add_sys_logger(logger): logging.getLogger(logger).addHandler(handler) def add_mail_logger(logger, addr): + """Adding e-mail logger + + :param addr: comma-separated addresses + :type addr: str + + :return: - + :rtype: None + """ if not addr: return + addresses = addr.split(',') handler = logging.handlers.SMTPHandler("localhost", "%s@%s" % (pwd.getpwuid(os.getuid())[0], socket.getfqdn()), - addr, + addresses, "%s: error notice" % socket.getfqdn()) handler.setFormatter(logging.Formatter('%(pathname)s:%(lineno)d [%(levelname)s] %(message)s')) handler.setLevel(logging.ERROR) diff --git a/vm/kojivmd b/vm/kojivmd index b37a9557..ff616d80 100755 --- a/vm/kojivmd +++ b/vm/kojivmd @@ -91,7 +91,8 @@ def get_options(): help="don't actually run main") parser.add_option("--maxjobs", type='int', help="Specify maxjobs") parser.add_option("--sleeptime", type='int', help="Specify the polling interval") - parser.add_option("--admin-emails", help="Address(es) to send error notices to") + parser.add_option("--admin-emails", type='str', action="store", metavar="EMAILS", + help="Comma-separated addresses to send error notices to.") parser.add_option("--workdir", help="Specify workdir") parser.add_option("--pluginpath", help="Specify plugin search path") parser.add_option("--plugin", action="append", help="Load specified plugin")