diff -r 7828b9c7be43 -r 6eb7c69356f6 buildbot/scheduler.py
|
a
|
b
|
|
| 53 | 53 | pass |
| 54 | 54 | |
| 55 | 55 | class BaseUpstreamScheduler(BaseScheduler): |
| 56 | 56 | implements(interfaces.IUpstreamScheduler) |
| 57 | 57 | |
| 58 | 58 | def __init__(self, name, properties={}): |
| 59 | 59 | BaseScheduler.__init__(self, name, properties) |
| 60 | 60 | self.successWatchers = [] |
| | 61 | self.failureWatchers = [] |
| | 62 | self.startWatchers = [] |
| 61 | 63 | |
| | 64 | # these two functions are superceded by the two below, but are being |
| | 65 | # kept to accomodate existing code. |
| | 66 | # TODO: remove them |
| 62 | 67 | def subscribeToSuccessfulBuilds(self, watcher): |
| 63 | | self.successWatchers.append(watcher) |
| | 68 | self.subscribeToBuilds(watcher) |
| 64 | 69 | def unsubscribeToSuccessfulBuilds(self, watcher): |
| 65 | | self.successWatchers.remove(watcher) |
| | 70 | self.unsubscribeToBuilds(watcher) |
| | 71 | |
| | 72 | def subscribeToBuilds(self, watcher, start=False, success=True, |
| | 73 | failure=False): |
| | 74 | if start: |
| | 75 | self.startWatchers.append(watcher) |
| | 76 | if success: |
| | 77 | self.successWatchers.append(watcher) |
| | 78 | if failure: |
| | 79 | self.failureWatchers.append(watcher) |
| | 80 | |
| | 81 | def unsubscribeToBuilds(self, watcher, start=False, success=True, |
| | 82 | failure=False): |
| | 83 | if start: |
| | 84 | self.startWatchers.remove(watcher) |
| | 85 | if success: |
| | 86 | self.successWatchers.remove(watcher) |
| | 87 | if failure: |
| | 88 | self.failureWatchers.remove(watcher) |
| 66 | 89 | |
| 67 | 90 | def submitBuildSet(self, bs): |
| 68 | 91 | d = bs.waitUntilFinished() |
| 69 | 92 | d.addCallback(self.buildSetFinished) |
| | 93 | for w in self.startWatchers: |
| | 94 | w(bs.source) |
| 70 | 95 | BaseScheduler.submitBuildSet(self, bs) |
| 71 | 96 | |
| 72 | 97 | def buildSetFinished(self, bss): |
| 73 | 98 | if not self.running: |
| 74 | 99 | return |
| | 100 | ss = bss.getSourceStamp() |
| 75 | 101 | if bss.getResults() == builder.SUCCESS: |
| 76 | | ss = bss.getSourceStamp() |
| 77 | 102 | for w in self.successWatchers: |
| | 103 | w(ss) |
| | 104 | else: |
| | 105 | for w in self.failureWatchers: |
| 78 | 106 | w(ss) |
| 79 | 107 | |
| 80 | 108 | |
| 81 | 109 | class Scheduler(BaseUpstreamScheduler): |
| 82 | 110 | """The default Scheduler class will run a build after some period of time |
| 83 | 111 | called the C{treeStableTimer}, on a given set of Builders. It only pays |
| 84 | 112 | attention to a single branch. You you can provide a C{fileIsImportant} |
| 85 | 113 | function which will evaluate each Change to decide whether or not it |