Bill Nottingham 666c04c
commit 35eae6232b985faec7a137a3ab5af03fddc27b78
Bill Nottingham 666c04c
Author: Bill Nottingham <notting@redhat.com>
Bill Nottingham 666c04c
Date:   Thu Jan 5 15:18:22 2012 -0500
Bill Nottingham 666c04c
Bill Nottingham 666c04c
    Add some basic support for overriding mail from/to addresses. (#739166)
Bill Nottingham 666c04c
Bill Nottingham 666c04c
diff --git a/utils/spam-o-matic b/utils/spam-o-matic
Bill Nottingham 666c04c
index a1cbc98..ba9e059 100755
Bill Nottingham 666c04c
--- a/utils/spam-o-matic
Bill Nottingham 666c04c
+++ b/utils/spam-o-matic
Bill Nottingham 666c04c
@@ -21,6 +21,9 @@ import repoclosure
Bill Nottingham 666c04c
 owners = {}
Bill Nottingham 666c04c
 deps = {}
Bill Nottingham 666c04c
 
Bill Nottingham 666c04c
+owner_template = "%s-owner@fedoraproject.org"
Bill Nottingham 666c04c
+from_address = "buildsys@fedoraproject.org"
Bill Nottingham 666c04c
+
Bill Nottingham 666c04c
 def generateConfig(distdir, treename, arch):
Bill Nottingham 666c04c
     if not os.path.exists(os.path.join(distdir, arch)):
Bill Nottingham 666c04c
         return None
Bill Nottingham 666c04c
@@ -67,7 +70,7 @@ def addOwner(list, pkg):
Bill Nottingham 666c04c
     if list.has_key(pkg):
Bill Nottingham 666c04c
         return False
Bill Nottingham 666c04c
 
Bill Nottingham 666c04c
-    f = "%s-owner@fedoraproject.org" % pkg
Bill Nottingham 666c04c
+    f = owner_template % pkg
Bill Nottingham 666c04c
     list[pkg] = f
Bill Nottingham 666c04c
     if f:
Bill Nottingham 666c04c
         return True
Bill Nottingham 666c04c
@@ -153,7 +156,7 @@ def generateSpam(pkgname, treename, sendmail = True):
Bill Nottingham 666c04c
 
Bill Nottingham 666c04c
     data = data + "Please resolve this as soon as possible.\n\n"
Bill Nottingham 666c04c
     
Bill Nottingham 666c04c
-    fromaddr = 'buildsys@fedoraproject.org'
Bill Nottingham 666c04c
+    fromaddr = from_address
Bill Nottingham 666c04c
     toaddrs = [guilty]
Bill Nottingham 666c04c
     if conspirators:
Bill Nottingham 666c04c
         toaddrs = toaddrs + conspirators
Bill Nottingham 666c04c
@@ -244,8 +247,14 @@ def doit(dir, treename, mail=True):
Bill Nottingham 666c04c
 if __name__ == '__main__':
Bill Nottingham 666c04c
 
Bill Nottingham 666c04c
     parser = OptionParser("usage: %prog [options] <directory>")
Bill Nottingham 666c04c
-    parser.add_option("--nomail", action="store_true")
Bill Nottingham 666c04c
-    parser.add_option("--treename", default="rawhide")
Bill Nottingham 666c04c
+    parser.add_option("--nomail", action="store_true",
Bill Nottingham 666c04c
+                      help="Don't mail the results")
Bill Nottingham 666c04c
+    parser.add_option("--treename", default="rawhide",
Bill Nottingham 666c04c
+                      help="Name of the tree to use in messages")
Bill Nottingham 666c04c
+    parser.add_option("--fromaddr", default="buildsys@fedoraproject.org",
Bill Nottingham 666c04c
+                      help="Address to send mail from (default: buildsys@fedoraproject.org)")
Bill Nottingham 666c04c
+    parser.add_option("--owneraddr", default="%s-owner@fedoraproject.org",
Bill Nottingham 666c04c
+                      help="Template for package owner addresses to send mail to (default: %s-owner@fedoraproject.org)")
Bill Nottingham 666c04c
     (options, args) = parser.parse_args(sys.argv[1:])
Bill Nottingham 666c04c
     if len(args) != 1:
Bill Nottingham 666c04c
         parser.error("incorrect number of arguments")
Bill Nottingham 666c04c
@@ -254,4 +263,8 @@ if __name__ == '__main__':
Bill Nottingham 666c04c
         mail = False
Bill Nottingham 666c04c
     else:
Bill Nottingham 666c04c
         mail = True
Bill Nottingham 666c04c
+    if options.fromaddr:
Bill Nottingham 666c04c
+        from_address = options.fromaddr
Bill Nottingham 666c04c
+    if options.owneraddr:
Bill Nottingham 666c04c
+        owner_template = options.owneraddr
Bill Nottingham 666c04c
     doit(args[0], options.treename, mail)