Trees | Indices | Help |
|
---|
|
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 from twisted.python import failure 17 from twisted.internet import defer 18 from buildbot.schedulers import base 19 from buildbot.process.properties import Properties 2022 23 compare_attrs = base.BaseScheduler.compare_attrs 245526 base.BaseScheduler.__init__(self, name, builderNames, properties) 27 self._waiters = {} 28 self._bsc_subscription = None 29 self.reason = "Triggerable(%s)" % name3032 """Trigger this scheduler with the given sourcestamp ID. Returns a 33 deferred that will fire when the buildset is finished.""" 34 # properties for this buildset are composed of our own properties, 35 # potentially overridden by anything from the triggering build 36 props = Properties() 37 props.updateFromProperties(self.properties) 38 if set_props: 39 props.updateFromProperties(set_props) 40 41 # note that this does not use the buildset subscriptions mechanism, as 42 # the duration of interest to the caller is bounded by the lifetime of 43 # this process. 44 if ssid: 45 d = self.addBuildsetForSourceStamp(reason=self.reason, ssid=ssid, 46 properties=props) 47 else: 48 d = self.addBuildsetForLatest(reason=self.reason, properties=props) 49 def setup_waiter((bsid,brids)): 50 self._waiters[bsid] = d = defer.Deferred() 51 self._updateWaiters() 52 return d53 d.addCallback(setup_waiter) 54 return d57 # cancel any outstanding subscription 58 if self._bsc_subscription: 59 self._bsc_subscription.unsubscribe() 60 self._bsc_subscription = None 61 62 # and errback any outstanding deferreds 63 if self._waiters: 64 msg = 'Triggerable scheduler stopped before build was complete' 65 for d in self._waiters.values(): 66 d.errback(failure.Failure(RuntimeError(msg))) 67 self._waiters = {} 68 69 return base.BaseScheduler.stopService(self)7072 if self._waiters and not self._bsc_subscription: 73 self._bsc_subscription = \ 74 self.master.subscribeToBuildsetCompletions( 75 self._buildsetComplete) 76 elif not self._waiters and self._bsc_subscription: 77 self._bsc_subscription.unsubscribe() 78 self._bsc_subscription = None7981 if bsid not in self._waiters: 82 return 83 84 # pop this bsid from the waiters list, and potentially unsubscribe 85 # from completion notifications 86 d = self._waiters.pop(bsid) 87 self._updateWaiters() 88 89 # fire the callback to indicate that the triggered build is complete 90 d.callback(result)91
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sun Jul 17 13:45:38 2011 | http://epydoc.sourceforge.net |