3 """ Manage build queues
5 @contact: Debian FTPMaster <ftpmaster@debian.org>
6 @copyright: 2000, 2001, 2002, 2006 James Troup <james@nocrew.org>
7 @copyright: 2009 Mark Hymers <mhy@debian.org>
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2 of the License, or
14 # (at your option) any later version.
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 ################################################################################
31 from datetime import datetime
34 from daklib import daklog
35 from daklib.dbconn import *
36 from daklib.config import Config
38 ################################################################################
43 ################################################################################
45 def usage (exit_code=0):
46 print """Usage: dak manage-build-queues [OPTIONS] buildqueue1 buildqueue2
47 Manage the contents of one or more build queues
49 -a, --all run on all known build queues
50 -n, --no-action don't do anything
51 -h, --help show this help and exit"""
55 ################################################################################
58 global Options, Logger
62 for i in ["Help", "No-Action", "All"]:
63 if not cnf.has_key("Manage-Build-Queues::Options::%s" % (i)):
64 cnf["Manage-Build-Queues::Options::%s" % (i)] = ""
66 Arguments = [('h',"help","Manage-Build-Queues::Options::Help"),
67 ('n',"no-action","Manage-Build-Queues::Options::No-Action"),
68 ('a',"all","Manage-Build-Queues::Options::All")]
70 queue_names = apt_pkg.ParseCommandLine(cnf.Cnf, Arguments, sys.argv)
71 Options = cnf.SubTree("Manage-Build-Queues::Options")
76 Logger = daklog.Logger(cnf, 'manage-build-queues', Options['No-Action'])
78 starttime = datetime.now()
80 session = DBConn().session()
83 if len(queue_names) != 0:
84 print "E: Cannot use both -a and a queue_name"
86 queues = session.query(BuildQueue).all()
91 queue = get_build_queue(q.lower(), session)
95 Logger.log(['cannot find queue %s' % q])
97 # For each given queue, look up object and call manage_queue
99 Logger.log(['cleaning queue %s using datetime %s' % (q.queue_name, starttime)])
100 q.clean_and_update(starttime, Logger, dryrun=Options["No-Action"])
104 #######################################################################################
106 if __name__ == '__main__':