X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dak%2Fbts_categorize.py;h=9112178452adaa6eb8853a769ac01d7897052759;hb=0d80b258098ff470433efa4d9c1f81b404883195;hp=3a3a8899f186e879cbe4158504a378dfb68f916a;hpb=564395db9f6a393a894fa1b2f7ff5aefcfadd2b7;p=dak.git diff --git a/dak/bts_categorize.py b/dak/bts_categorize.py index 3a3a8899..91121784 100755 --- a/dak/bts_categorize.py +++ b/dak/bts_categorize.py @@ -1,9 +1,11 @@ #!/usr/bin/python -# bts -- manage bugs filed against ftp.debian.org -# -# Copyright 2009 Mike O'Connor -# +""" +bts -- manage bugs filed against ftp.debian.org + +Copyright 2009 Mike O'Connor +""" + # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 2, or (at your option) any @@ -22,19 +24,19 @@ ################################################################################ ################################################################################ +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 +62,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 @@ -124,7 +117,7 @@ class BugClassifier(object): return retval def email_text(self): - controls = 'user ftp.debian.org@packages.debian.org\n' + controls = "" bc = BugClassifier() for bug in bc.unclassified_bugs(): @@ -132,20 +125,19 @@ class BugClassifier(object): return controls +def send_email(commands, simulate=False): + global Cnf + + Subst = {'__COMMANDS__' : commands, + "__DAK_ADDRESS__": Cnf["Dinstall::MyAdminAddress"]} -import smtplib -import email.Message + bts_mail_message = utils.TemplateSubst( + Subst,Cnf["Dir::Templates"]+"/bts-categorize") -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() + if simulate: + print bts_mail_message + else: + utils.send_mail( bts_mail_message ) def main(): """ @@ -182,11 +174,11 @@ def main(): body = BugClassifier().email_text() - if Options["Simulate"]: - print body + if body: + send_email(body, Options["Simulate"]) else: - send_email(body) + log.info( "nothing to do" ) if __name__ == '__main__':