1# This file is part of Buildbot. Buildbot is free software: you can 2# redistribute it and/or modify it under the terms of the GNU General Public 3# License as published by the Free Software Foundation, version 2. 4# 5# This program is distributed in the hope that it will be useful, but WITHOUT 6# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 7# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 8# details. 9# 10# You should have received a copy of the GNU General Public License along with 11# this program; if not, write to the Free Software Foundation, Inc., 51 12# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 13# 14# Copyright Buildbot Team Members 15 16""" 17(Very partial) support for builds in the database 18""" 19 20fromtwisted.internetimportreactor 21frombuildbot.dbimportbase 22frombuildbot.utilimportepoch2datetime 23

25""" 26 A DBConnectorComponent to handle a little bit of information about builds. 27 Avaialble at C{master.db.buildrequests}. 28 29 NOTE: The interface for this module will change - the builds table 30 duplicates some information available in pickles, without including all 31 such information. Do not depend on this API. 32 33 Note that a single build may be represented in many rows in the builds 34 table, as it the builds table represents 35 36 Builds are represented as dictionaries with keys C{bid} (the build ID, 37 globally unique), C{number} (the build number, unique only within this 38 master and builder), C{brid} (the ID of the build request that caused this 39 build), C{start_time}, and C{finish_time} (datetime objects, or None). 40 """ 41

102"""103104 Mark builds as finished, with C{finish_time} now. This is done105 unconditionally, even if the builds are already finished.106107 @param bids: build ids108 @type bids: list109110 @param _reactor: reactor to use (for testing)111112 @returns: Deferred113 """114defthd(conn):115tbl=self.db.model.builds116now=_reactor.seconds()117118# split the bids into batches, so as not to overflow the parameter119# lists of the database interface120remaining=bids121whileremaining:122batch,remaining=remaining[:100],remaining[100:]123q=tbl.update(whereclause=(tbl.c.id.in_(batch)))124conn.execute(q,finish_time=now)