From 42572874d9d2e5f4e1de0ce21d4c5e223307716a Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Nov 18 2019 08:54:18 +0000 Subject: 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 --- diff --git a/builder/kojid b/builder/kojid index 6e67965..0ec45a3 100755 --- a/builder/kojid +++ b/builder/kojid @@ -6090,7 +6090,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 3144507..b99c88b 100644 --- a/koji/__init__.py +++ b/koji/__init__.py @@ -3436,11 +3436,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 24ca674..f8e21c4 100755 --- a/vm/kojivmd +++ b/vm/kojivmd @@ -88,7 +88,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")