]> git.decadent.org.uk Git - dak.git/commitdiff
Use dak's facility for sending email. Add bts-categorize to cron.dinstall
authorMike O'Connor <stew@vireo.org>
Sun, 25 Jan 2009 16:16:28 +0000 (11:16 -0500)
committerMike O'Connor <stew@vireo.org>
Sun, 25 Jan 2009 16:16:28 +0000 (11:16 -0500)
Signed-off-by: Mike O'Connor <stew@vireo.org>
config/debian/cron.dinstall
dak/bts_categorize.py
templates/bts-categorize [new file with mode: 0644]

index 403a03fdf96c4d61a5e0a96eb7b1ac7acb4eaa0a..afa2571074eb82bb34e752380a3cb592b9126006 100755 (executable)
@@ -256,6 +256,9 @@ ts "reports"
 echo "Updating DM html page"
 $scriptsdir/dm-monitor >$webdir/dm-uploaders.html
 
+echo "Categorizing uncategorized bugs filed against ftp.debian.org"
+dak bts-categorize
+
 ################################################################################
 
 # Push katie@merkel so it syncs the projectb there. Returns immediately, the sync runs detached
index 11fc18c61b60ca6a3a899c222db6c973da953508..1a4548e67c07d2766bcc7dfa60b6d0b68c629e36 100755 (executable)
 ################################################################################
 ################################################################################
 
+import sys
+import re
+import logging
+log = logging.getLogger()
+
+import apt_pkg
+from daklib import utils
+from btsutils.debbugs import debbugs
+
 def usage():
     print """
 SYNOPSIS
-    dak bts-categorize [options] command
-
-COMMANDS
-    list-categories
-        List the currently defind categorizations for bugs
-
-    categorize
-        Find the bugs filed against ftp.debian.org which have no usertag
-        and see if we can categorize the bug by adding a usertag by matching
-        the subject against a list of regexps.
+    dak bts-categorize [options]
 
 OPTIONS
     -s
@@ -60,15 +60,6 @@ arguments = [('s','simulate','BtsCategorize::Options::Simulate'),
              ('q', 'quiet', 'BtsCategorize::Options::Quiet'),
              ('h', 'help', 'BtsCategorize::Options::Help')]
 
-import sys
-import re
-import logging
-log = logging.getLogger()
-
-import apt_pkg
-from daklib import utils
-from btsutils.debbugs import debbugs
-
 class BugClassifier(object):
     """
     classify bugs using usertags based on the bug subject lines
@@ -130,22 +121,24 @@ class BugClassifier(object):
         for bug in bc.unclassified_bugs():
             controls += bc.classify_bug(bug)
 
-        if controls:
-            return 'user ftp.debian.org@packages.debian.org\n' + controls
+        return controls
 
 import smtplib
 import email.Message
 
-def send_email(body):
-    to = 'control@bugs.debian.org'
-    sender = 'ak@ries.debian.org'
-    message = email.Message.Message()
-    message["To"] = to
-    message["From"] = sender
-    message.set_payload(body)
-    mailServer = smtplib.SMTP('localhost')
-    mailServer.sendmail(sender, to, message.as_string())
-    mailServer.quit()
+def send_email(commands, simulate):
+    global Cnf
+
+    Subst = {'__COMMANDS__' : commands,
+             "__DAK_ADDRESS__": Cnf["Dinstall::MyAdminAddress"]}
+
+    bts_mail_message = utils.TemplateSubst(
+        Subst,Cnf["Dir::Templates"]+"/bts-categorize")
+
+    if simulate:
+        print bts_mail_message
+    else:
+        utils.send_mail( bts_mail_message )
 
 def main():
     """
@@ -183,10 +176,7 @@ def main():
     body = BugClassifier().email_text()
 
     if body:
-        if Options["Simulate"]:
-            print body
-        else:
-            send_email(body)
+        send_email(body, Options["Simulate"])
 
     else:
         log.info( "nothing to do" )
diff --git a/templates/bts-categorize b/templates/bts-categorize
new file mode 100644 (file)
index 0000000..7f43e1a
--- /dev/null
@@ -0,0 +1,6 @@
+From: __DAK_ADDRESS__
+To: control@bugs.debian.org
+X-Debian: DAK
+
+user ftp.debian.org@packages.debian.org
+__COMMANDS__