Add get_by_checksum function.
[amitay/build-farm.git] / builds.py
1 #!/usr/bin/python
2 # Samba.org buildfarm
3 # Copyright (C) 2010 Jelmer Vernooij <jelmer@samba.org>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 #
18
19 from buildfarm.sqldb import StormCachingBuildFarm
20 import optparse
21 import sys
22
23 parser = optparse.OptionParser("")
24 parser.add_option("--tree", help="Print builds for a specific tree.", type=str)
25 parser.add_option("--last", help="Print last builds.", action="store_true")
26
27 (opts, args) = parser.parse_args()
28
29 buildfarm = StormCachingBuildFarm()
30
31 if opts.tree:
32     builds = buildfarm.get_tree_builds(opts.tree)
33 elif opts.last:
34     builds = buildfarm.get_last_builds()
35 else:
36     parser.print_usage()
37     sys.exit(1)
38
39 for build in builds:
40     print build