X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=alicia;h=1627474c064de049d091e2bfd460520300dc0d88;hb=80b0cf4b95f879ce7e6e41297bced5c4e955f697;hp=39fab4773caf131ac0cd6acfd6bccbc4d3929df7;hpb=105374b0eaca7dc32195f890c068cb167fad72fd;p=dak.git diff --git a/alicia b/alicia index 39fab477..1627474c 100755 --- a/alicia +++ b/alicia @@ -2,7 +2,7 @@ # Microscopic modification and query tool for overrides in projectb # Copyright (C) 2004 Daniel Silverstone -# $Id: alicia,v 1.2 2004-01-29 10:40:18 dsilvers Exp $ +# $Id: alicia,v 1.6 2004-11-27 17:58:13 troup Exp $ # 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 @@ -26,7 +26,7 @@ ## That Alisha Rules The World ################################################################################ -import pg, pwd, sys; +import pg, sys; import utils, db_access; import apt_pkg, logging; @@ -50,6 +50,7 @@ def usage (exit_code=0): Make microchanges or microqueries of the overrides -h, --help show this help and exit + -d, --done=BUG# send priority/section change as closure to bug# -n, --no-action don't do anything -s, --suite specify the suite to use """ @@ -61,6 +62,7 @@ def main (): Cnf = utils.get_conf() Arguments = [('h',"help","Alicia::Options::Help"), + ('d',"done","Alicia::Options::Done", "HasArg"), ('n',"no-action","Alicia::Options::No-Action"), ('s',"suite","Alicia::Options::Suite", "HasArg"), ]; @@ -83,7 +85,7 @@ def main (): utils.fubar("package name is a required argument."); package = arguments.pop(0); - + suite = Options["Suite"] if arguments and len(arguments) > 2: utils.fubar("Too many arguments"); @@ -101,7 +103,7 @@ def main (): arguments = (".",arg); else: utils.fubar("%s is not a valid section or priority" % (arg)); - + # Retrieve current section/priority... q = projectB.query(""" @@ -112,7 +114,7 @@ def main (): AND override.package = %s AND override.suite = suite.id AND suite.suite_name = %s - """ % (pg._quote(package,"str"), pg._quote(Options["Suite"],"str"))); + """ % (pg._quote(package,"str"), pg._quote(suite,"str"))); if q.ntuples() == 0: utils.fubar("Unable to find package %s" % (package)); @@ -135,14 +137,14 @@ def main (): newsection = oldsection; if newpriority == ".": newpriority = oldpriority; - + q = projectB.query("SELECT id FROM section WHERE section=%s" % ( pg._quote(newsection,"str"))); if q.ntuples() == 0: utils.fubar("Supplied section %s is invalid" % (newsection)); newsecid = q.getresult()[0][0]; - + q = projectB.query("SELECT id FROM priority WHERE priority=%s" % ( pg._quote(newpriority,"str"))); @@ -153,13 +155,16 @@ def main (): if newpriority == oldpriority and newsection == oldsection: print "I: Doing nothing" sys.exit(0); - + # If we're in no-action mode if Options["No-Action"]: if newpriority != oldpriority: print "I: Would change priority from %s to %s" % (oldpriority,newpriority); if newsection != oldsection: print "I: Would change section from %s to %s" % (oldsection,newsection); + if Options.has_key("Done"): + print "I: Would also close bug(s): %s" % (Options["Done"]); + sys.exit(0); if newpriority != oldpriority: @@ -167,6 +172,12 @@ def main (): if newsection != oldsection: print "I: Will change section from %s to %s" % (oldsection,newsection); + if not Options.has_key("Done"): + pass; + #utils.warn("No bugs to close have been specified. Noone will know you have done this."); + else: + print "I: Will close bug(s): %s" % (Options["Done"]); + game_over(); Logger = logging.Logger(Cnf, "alicia"); @@ -181,7 +192,7 @@ def main (): AND suite = (SELECT id FROM suite WHERE suite_name=%s)""" % ( newprioid, pg._quote(package,"str"), - pg._quote(Options["Suite"],"str") )); + pg._quote(suite,"str") )); Logger.log(["changed priority",package,oldpriority,newpriority]); if newsection != oldsection: @@ -192,14 +203,47 @@ def main (): AND suite = (SELECT id FROM suite WHERE suite_name=%s)""" % ( newsecid, pg._quote(package,"str"), - pg._quote(Options["Suite"],"str") )); + pg._quote(suite,"str") )); Logger.log(["changed priority",package,oldsection,newsection]); projectB.query("COMMIT WORK"); + if Options.has_key("Done"): + Subst = {}; + Subst["__ALICIA_ADDRESS__"] = Cnf["Alicia::MyEmailAddress"]; + Subst["__BUG_SERVER__"] = Cnf["Dinstall::BugServer"]; + bcc = []; + if Cnf.Find("Dinstall::Bcc") != "": + bcc.append(Cnf["Dinstall::Bcc"]); + if Cnf.Find("Alicia::Bcc") != "": + bcc.append(Cnf["Alicia::Bcc"]); + if bcc: + Subst["__BCC__"] = "Bcc: " + ", ".join(bcc); + else: + Subst["__BCC__"] = "X-Filler: 42"; + Subst["__CC__"] = "X-Katie: alicia $Revision: 1.6 $"; + Subst["__ADMIN_ADDRESS__"] = Cnf["Dinstall::MyAdminAddress"]; + Subst["__DISTRO__"] = Cnf["Dinstall::MyDistribution"]; + Subst["__WHOAMI__"] = utils.whoami(); + + summary = "Concerning package %s...\n" % (package); + summary += "Operating on the %s suite\n" % (suite); + if newpriority != oldpriority: + summary += "Changed priority from %s to %s\n" % (oldpriority,newpriority); + if newsection != oldsection: + summary += "Changed section from %s to %s\n" % (oldsection,newsection); + Subst["__SUMMARY__"] = summary; + + for bug in utils.split_args(Options["Done"]): + Subst["__BUG_NUMBER__"] = bug; + mail_message = utils.TemplateSubst( + Subst,Cnf["Dir::Templates"]+"/alicia.bug-close"); + utils.send_mail(mail_message); + Logger.log(["closed bug",bug]); + Logger.close(); print "Done"; - + ################################################################################# if __name__ == '__main__':