From 81cc83ec881d890499108b469044559c9861b214 Mon Sep 17 00:00:00 2001 From: Alex Iribarren Date: Jan 08 2020 12:25:43 +0000 Subject: [PATCH 1/2] Add CC/BCC for email notifications --- diff --git a/util/koji-gc b/util/koji-gc index f4d0943..adbf9b6 100755 --- a/util/koji-gc +++ b/util/koji-gc @@ -84,6 +84,8 @@ def get_options(): help=_("Email domain appended to Koji username for notifications")) parser.add_option("--from-addr", default="Koji Build System ", help=_("From address for notifications")) + parser.add_option("--cc-addr", help=_("CC address for notifications")) + parser.add_option("--bcc-addr", help=_("BCC address for notifications")) parser.add_option("--email-template", default="/etc/koji-gc/email.tpl", help=_("notification template")) parser.add_option("--action", help=_("action(s) to take")) @@ -139,6 +141,8 @@ def get_options(): ['weburl', None, 'string'], ['smtp_host', None, 'string'], ['from_addr', None, 'string'], + ['cc_addr', None, 'string'], + ['bcc_addr', None, 'string'], ['email_template', None, 'string'], ['email_domain', None, 'string'], ['mail', None, 'boolean'], @@ -405,21 +409,28 @@ Build: %%(name)s-%%(version)s-%%(release)s msg['Subject'] = "%i builds marked for deletion" % len(builds) msg['From'] = options.from_addr msg['To'] = "%s@%s" % (owner_name, options.email_domain) #XXX! + emails = [msg['To']] + if options.cc_addr: + msg['Cc'] = options.cc_addr + emails.append(msg['Cc']) + if options.bcc_addr: + msg['Bcc'] = options.bcc_addr + emails.append(msg['Bcc']) msg['X-Koji-Builder'] = owner_name if options.test: if options.debug: print(str(msg)) else: - print("Would have sent warning notice to %s" % msg['To']) + print("Would have sent warning notice to %s" % emails) else: if options.debug: - print("Sending warning notice to %s" % msg['To']) + print("Sending warning notice to %s" % emails) try: s = smtplib.SMTP(options.smtp_host) - s.sendmail(msg['From'], msg['To'], msg.as_string()) + s.sendmail(msg['From'], emails, msg.as_string()) s.quit() except: - print("FAILED: Sending warning notice to %s" % msg['To']) + print("FAILED: Sending warning notice to %s" % emails) def main(args): From 09c601d922caf90fdfc47d55cf37daf822f8b4ba Mon Sep 17 00:00:00 2001 From: Alex Iribarren Date: Jan 08 2020 12:26:26 +0000 Subject: [PATCH 2/2] Fix indentation --- diff --git a/util/koji-gc b/util/koji-gc index adbf9b6..63ec653 100755 --- a/util/koji-gc +++ b/util/koji-gc @@ -129,7 +129,7 @@ def get_options(): ['krbservice', None, 'string'], ['krb_rdns', None, 'boolean'], ['krb_canon_host', None, 'boolean'], - ['krb_server_realm', None, 'string'], + ['krb_server_realm', None, 'string'], ['runas', None, 'string'], ['user', None, 'string'], ['password', None, 'string'],