Package buildbot :: Module interfaces
[frames] | no frames]

Source Code for Module buildbot.interfaces

   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  """Interface documentation. 
  17   
  18  Define the interfaces that are implemented by various buildbot classes. 
  19  """ 
  20  # E0211: Method has no argument 
  21  # E0213: Method should have "self" as first argument 
  22  # pylint: disable-msg=E0211,E0213 
  23   
  24  from zope.interface import Interface, Attribute 
  25   
  26  # exceptions that can be raised while trying to start a build 
27 -class NoSlaveError(Exception):
28 pass
29 -class BuilderInUseError(Exception):
30 pass
31 -class BuildSlaveTooOldError(Exception):
32 pass
33 -class LatentBuildSlaveFailedToSubstantiate(Exception):
34 pass
35
36 -class IChangeSource(Interface):
37 """ 38 Service which feeds Change objects to the changemaster. When files or 39 directories are changed in version control, this object should represent 40 the changes as a change dictionary and call:: 41 42 self.master.addChange(who=.., rev=.., ..) 43 44 See 'Writing Change Sources' in the manual for more information. 45 """ 46 master = Attribute('master', 47 'Pointer to BuildMaster, automatically set when started.') 48
49 - def describe():
50 """Return a string which briefly describes this source."""
51
52 -class ISourceStamp(Interface):
53 """ 54 @cvar branch: branch from which source was drawn 55 @type branch: string or None 56 57 @cvar revision: revision of the source, or None to use CHANGES 58 @type revision: varies depending on VC 59 60 @cvar patch: patch applied to the source, or None if no patch 61 @type patch: None or tuple (level diff) 62 63 @cvar changes: the source step should check out the latest revision 64 in the given changes 65 @type changes: tuple of L{buildbot.changes.changes.Change} instances, 66 all of which are on the same branch 67 68 @cvar project: project this source code represents 69 @type project: string 70 71 @cvar repository: repository from which source was drawn 72 @type repository: string 73 """ 74
75 - def canBeMergedWith(self, other):
76 """ 77 Can this SourceStamp be merged with OTHER? 78 """
79
80 - def mergeWith(self, others):
81 """Generate a SourceStamp for the merger of me and all the other 82 SourceStamps. This is called by a Build when it starts, to figure 83 out what its sourceStamp should be."""
84
85 - def getAbsoluteSourceStamp(self, got_revision):
86 """Get a new SourceStamp object reflecting the actual revision found 87 by a Source step."""
88
89 - def getText(self):
90 """Returns a list of strings to describe the stamp. These are 91 intended to be displayed in a narrow column. If more space is 92 available, the caller should join them together with spaces before 93 presenting them to the user."""
94
95 -class IEmailSender(Interface):
96 """I know how to send email, and can be used by other parts of the 97 Buildbot to contact developers.""" 98 pass
99
100 -class IEmailLookup(Interface):
101 - def getAddress(user):
102 """Turn a User-name string into a valid email address. Either return 103 a string (with an @ in it), None (to indicate that the user cannot 104 be reached by email), or a Deferred which will fire with the same."""
105
106 -class IStatus(Interface):
107 """I am an object, obtainable from the buildmaster, which can provide 108 status information.""" 109
110 - def getTitle():
111 """Return the name of the project that this Buildbot is working 112 for."""
113 - def getTitleURL():
114 """Return the URL of this Buildbot's project."""
115 - def getBuildbotURL():
116 """Return the URL of the top-most Buildbot status page, or None if 117 this Buildbot does not provide a web status page."""
118 - def getURLForThing(thing):
119 """Return the URL of a page which provides information on 'thing', 120 which should be an object that implements one of the status 121 interfaces defined in L{buildbot.interfaces}. Returns None if no 122 suitable page is available (or if no Waterfall is running)."""
123
124 - def getChangeSources():
125 """Return a list of IChangeSource objects."""
126
127 - def getChange(number):
128 """Return an IChange object."""
129
130 - def getSchedulers():
131 """Return a list of ISchedulerStatus objects for all 132 currently-registered Schedulers."""
133
134 - def getBuilderNames(categories=None):
135 """Return a list of the names of all current Builders."""
136 - def getBuilder(name):
137 """Return the IBuilderStatus object for a given named Builder. Raises 138 KeyError if there is no Builder by that name."""
139
140 - def getSlaveNames():
141 """Return a list of buildslave names, suitable for passing to 142 getSlave()."""
143 - def getSlave(name):
144 """Return the ISlaveStatus object for a given named buildslave."""
145
146 - def getBuildSets():
147 """ 148 Return a list of un-completed build sets. 149 150 @returns: list of L{IBuildSetStatus} implementations, via Deferred. 151 """
152
153 - def generateFinishedBuilds(builders=[], branches=[], 154 num_builds=None, finished_before=None, 155 max_search=200):
156 """Return a generator that will produce IBuildStatus objects each 157 time you invoke its .next() method, starting with the most recent 158 finished build and working backwards. 159 160 @param builders: this is a list of Builder names, and the generator 161 will only produce builds that ran on the given 162 Builders. If the list is empty, produce builds from 163 all Builders. 164 165 @param branches: this is a list of branch names, and the generator 166 will only produce builds that used the given 167 branches. If the list is empty, produce builds from 168 all branches. 169 170 @param num_builds: the generator will stop after providing this many 171 builds. The default of None means to produce as 172 many builds as possible. 173 174 @type finished_before: int: a timestamp, seconds since the epoch 175 @param finished_before: if provided, do not produce any builds that 176 finished after the given timestamp. 177 178 @type max_search: int 179 @param max_search: this method may have to examine a lot of builds 180 to find some that match the search parameters, 181 especially if there aren't any matching builds. 182 This argument imposes a hard limit on the number 183 of builds that will be examined within any given 184 Builder. 185 """
186
187 - def subscribe(receiver):
188 """Register an IStatusReceiver to receive new status events. The 189 receiver will immediately be sent a set of 'builderAdded' messages 190 for all current builders. It will receive further 'builderAdded' and 191 'builderRemoved' messages as the config file is reloaded and builders 192 come and go. It will also receive 'buildsetSubmitted' messages for 193 all outstanding BuildSets (and each new BuildSet that gets 194 submitted). No additional messages will be sent unless the receiver 195 asks for them by calling .subscribe on the IBuilderStatus objects 196 which accompany the addedBuilder message."""
197
198 - def unsubscribe(receiver):
199 """Unregister an IStatusReceiver. No further status messgaes will be 200 delivered."""
201
202 -class IBuildSetStatus(Interface):
203 """I represent a set of Builds, each run on a separate Builder but all 204 using the same source tree.""" 205
206 - def getReason():
207 pass
208 - def getID():
209 """Return the BuildSet's ID string, if any. The 'try' feature uses a 210 random string as a BuildSetID to relate submitted jobs with the 211 resulting BuildSet."""
212 - def getResponsibleUsers():
213 pass # not implemented
214 - def getInterestedUsers():
215 pass # not implemented
216 - def getBuilderNames():
217 """Return a list of the names of all Builders on which this set will 218 do builds. 219 220 @returns: list of names via Deferred"""
221 - def isFinished():
222 pass
223 - def waitUntilFinished():
224 """Return a Deferred that fires (with this IBuildSetStatus object) 225 when all builds have finished."""
226 - def getResults():
227 """Return SUCCESS/FAILURE, or None if the buildset is not finished 228 yet"""
229 230
231 -class IBuildRequestStatus(Interface):
232 """I represent a request to build a particular set of source code on a 233 particular Builder. These requests may be merged by the time they are 234 finally turned into a Build.""" 235
236 - def getSourceStamp():
237 """ 238 Get a SourceStamp object which can be used to re-create the source tree 239 that this build used. This method will return an absolute SourceStamp 240 if possible, and its results may change as the build progresses. 241 Specifically, a "HEAD" build may later be more accurately specified by 242 an absolute SourceStamp with the specific revision information. 243 244 This method will return None if the source information is no longer 245 available. 246 247 @returns: SourceStamp via Deferred 248 """
249
250 - def getBuilds():
251 """Return a list of IBuildStatus objects for each Build that has been 252 started in an attempt to satify this BuildRequest."""
253
254 - def subscribe(observer):
255 """Register a callable that will be invoked (with a single 256 IBuildStatus object) for each Build that is created to satisfy this 257 request. There may be multiple Builds created in an attempt to handle 258 the request: they may be interrupted by the user or abandoned due to 259 a lost slave. The last Build (the one which actually gets to run to 260 completion) is said to 'satisfy' the BuildRequest. The observer will 261 be called once for each of these Builds, both old and new."""
262 - def unsubscribe(observer):
263 """Unregister the callable that was registered with subscribe()."""
264 - def getSubmitTime():
265 """Return the time when this request was submitted. Returns a 266 Deferred."""
267 268
269 -class ISlaveStatus(Interface):
270 - def getName():
271 """Return the name of the build slave."""
272
273 - def getAdmin():
274 """Return a string with the slave admin's contact data."""
275
276 - def getHost():
277 """Return a string with the slave host info."""
278
279 - def isConnected():
280 """Return True if the slave is currently online, False if not."""
281
282 - def lastMessageReceived():
283 """Return a timestamp (seconds since epoch) indicating when the most 284 recent message was received from the buildslave."""
285
286 -class ISchedulerStatus(Interface):
287 - def getName():
288 """Return the name of this Scheduler (a string)."""
289
290 - def getPendingBuildsets():
291 """Return an IBuildSet for all BuildSets that are pending. These 292 BuildSets are waiting for their tree-stable-timers to expire."""
293 # TODO: this is not implemented anywhere 294 295
296 -class IBuilderStatus(Interface):
297 - def getName():
298 """Return the name of this Builder (a string)."""
299
300 - def getCategory():
301 """Return the category of this builder (a string)."""
302
303 - def getDescription():
304 """Return the description of this builder (a string)."""
305
306 - def getState():
307 # TODO: this isn't nearly as meaningful as it used to be 308 """Return a tuple (state, builds) for this Builder. 'state' is the 309 so-called 'big-status', indicating overall status (as opposed to 310 which step is currently running). It is a string, one of 'offline', 311 'idle', or 'building'. 'builds' is a list of IBuildStatus objects 312 (possibly empty) representing the currently active builds."""
313
314 - def getSlaves():
315 """Return a list of ISlaveStatus objects for the buildslaves that are 316 used by this builder."""
317
319 """ 320 Get a L{IBuildRequestStatus} implementations for all unclaimed build 321 requests. 322 323 @returns: list of objects via Deferred 324 """
325
326 - def getCurrentBuilds():
327 """Return a list containing an IBuildStatus object for each build 328 currently in progress."""
329 # again, we could probably provide an object for 'waiting' and 330 # 'interlocked' too, but things like the Change list might still be 331 # subject to change 332
333 - def getLastFinishedBuild():
334 """Return the IBuildStatus object representing the last finished 335 build, which may be None if the builder has not yet finished any 336 builds."""
337
338 - def getBuild(number):
339 """Return an IBuildStatus object for a historical build. Each build 340 is numbered (starting at 0 when the Builder is first added), 341 getBuild(n) will retrieve the Nth such build. getBuild(-n) will 342 retrieve a recent build, with -1 being the most recent build 343 started. If the Builder is idle, this will be the same as 344 getLastFinishedBuild(). If the Builder is active, it will be an 345 unfinished build. This method will return None if the build is no 346 longer available. Older builds are likely to have less information 347 stored: Logs are the first to go, then Steps."""
348
349 - def getEvent(number):
350 """Return an IStatusEvent object for a recent Event. Builders 351 connecting and disconnecting are events, as are ping attempts. 352 getEvent(-1) will return the most recent event. Events are numbered, 353 but it probably doesn't make sense to ever do getEvent(+n)."""
354
355 - def generateFinishedBuilds(branches=[], 356 num_builds=None, 357 max_buildnum=None, finished_before=None, 358 max_search=200, 359 ):
360 """Return a generator that will produce IBuildStatus objects each 361 time you invoke its .next() method, starting with the most recent 362 finished build, then the previous build, and so on back to the oldest 363 build available. 364 365 @param branches: this is a list of branch names, and the generator 366 will only produce builds that involve the given 367 branches. If the list is empty, the generator will 368 produce all builds regardless of what branch they 369 used. 370 371 @param num_builds: if provided, the generator will stop after 372 providing this many builds. The default of None 373 means to produce as many builds as possible. 374 375 @param max_buildnum: if provided, the generator will start by 376 providing the build with this number, or the 377 highest-numbered preceding build (i.e. the 378 generator will not produce any build numbered 379 *higher* than max_buildnum). The default of None 380 means to start with the most recent finished 381 build. -1 means the same as None. -2 means to 382 start with the next-most-recent completed build, 383 etc. 384 385 @type finished_before: int: a timestamp, seconds since the epoch 386 @param finished_before: if provided, do not produce any builds that 387 finished after the given timestamp. 388 389 @type max_search: int 390 @param max_search: this method may have to examine a lot of builds 391 to find some that match the search parameters, 392 especially if there aren't any matching builds. 393 This argument imposes a hard limit on the number 394 of builds that will be examined. 395 """
396
397 - def subscribe(receiver):
398 """Register an IStatusReceiver to receive new status events. The 399 receiver will be given builderChangedState, buildStarted, and 400 buildFinished messages."""
401
402 - def unsubscribe(receiver):
403 """Unregister an IStatusReceiver. No further status messgaes will be 404 delivered."""
405
406 -class IEventSource(Interface):
407 - def eventGenerator(branches=[], categories=[], committers=[], minTime=0):
408 """This function creates a generator which will yield all of this 409 object's status events, starting with the most recent and progressing 410 backwards in time. These events provide the IStatusEvent interface. 411 At the moment they are all instances of buildbot.status.builder.Event 412 or buildbot.status.builder.BuildStepStatus . 413 414 @param branches: a list of branch names. The generator should only 415 return events that are associated with these branches. If the list is 416 empty, events for all branches should be returned (i.e. an empty list 417 means 'accept all' rather than 'accept none'). 418 419 @param categories: a list of category names. The generator 420 should only return events that are categorized within the 421 given category. If the list is empty, events for all 422 categories should be returned. 423 424 @param comitters: a list of committers. The generator should only 425 return events caused by one of the listed committers. If the list is 426 empty or None, events from every committers should be returned. 427 428 @param minTime: a timestamp. Do not generate events occuring prior to 429 this timestamp. 430 """
431
432 -class IBuildStatus(Interface):
433 """I represent the status of a single Build/BuildRequest. It could be 434 in-progress or finished.""" 435
436 - def getBuilder():
437 """ 438 Return the BuilderStatus that owns this build. 439 440 @rtype: implementor of L{IBuilderStatus} 441 """
442
443 - def isFinished():
444 """Return a boolean. True means the build has finished, False means 445 it is still running."""
446
447 - def waitUntilFinished():
448 """Return a Deferred that will fire when the build finishes. If the 449 build has already finished, this deferred will fire right away. The 450 callback is given this IBuildStatus instance as an argument."""
451
452 - def getReason():
453 """Return a string that indicates why the build was run. 'changes', 454 'forced', and 'periodic' are the most likely values. 'try' will be 455 added in the future."""
456
457 - def getSourceStamps():
458 """Return a list of SourceStamp objects which can be used to re-create 459 the source tree that this build used. 460 461 This method will return None if the source information is no longer 462 available."""
463 # TODO: it should be possible to expire the patch but still remember 464 # that the build was r123+something. 465
466 - def getChanges():
467 """Return a list of Change objects which represent which source 468 changes went into the build."""
469
470 - def getRevisions():
471 """Returns a string representing the list of revisions that led to 472 the build, rendered from each Change.revision"""
473
474 - def getResponsibleUsers():
475 """Return a list of Users who are to blame for the changes that went 476 into this build. If anything breaks (at least anything that wasn't 477 already broken), blame them. Specifically, this is the set of users 478 who were responsible for the Changes that went into this build. Each 479 User is a string, corresponding to their name as known by the VC 480 repository."""
481
482 - def getInterestedUsers():
483 """Return a list of Users who will want to know about the results of 484 this build but who did not actually make the Changes that went into it 485 (build sheriffs, code-domain owners)."""
486
487 - def getNumber():
488 """Within each builder, each Build has a number. Return it."""
489
490 - def getPreviousBuild():
491 """Convenience method. Returns None if the previous build is 492 unavailable."""
493
494 - def getSteps():
495 """Return a list of IBuildStepStatus objects. For invariant builds 496 (those which always use the same set of Steps), this should always 497 return the complete list, however some of the steps may not have 498 started yet (step.getTimes()[0] will be None). For variant builds, 499 this may not be complete (asking again later may give you more of 500 them)."""
501
502 - def getTimes():
503 """Returns a tuple of (start, end). 'start' and 'end' are the times 504 (seconds since the epoch) when the Build started and finished. If 505 the build is still running, 'end' will be None."""
506 507 # while the build is running, the following methods make sense. 508 # Afterwards they return None 509
510 - def getETA():
511 """Returns the number of seconds from now in which the build is 512 expected to finish, or None if we can't make a guess. This guess will 513 be refined over time."""
514
515 - def getCurrentStep():
516 """Return an IBuildStepStatus object representing the currently 517 active step."""
518 519 # Once you know the build has finished, the following methods are legal. 520 # Before ths build has finished, they all return None. 521
522 - def getSlavename():
523 """Return the name of the buildslave which handled this build."""
524
525 - def getText():
526 """Returns a list of strings to describe the build. These are 527 intended to be displayed in a narrow column. If more space is 528 available, the caller should join them together with spaces before 529 presenting them to the user."""
530
531 - def getResults():
532 """Return a constant describing the results of the build: one of the 533 constants in buildbot.status.builder: SUCCESS, WARNINGS, 534 FAILURE, SKIPPED or EXCEPTION."""
535
536 - def getLogs():
537 """Return a list of logs that describe the build as a whole. Some 538 steps will contribute their logs, while others are are less important 539 and will only be accessible through the IBuildStepStatus objects. 540 Each log is an object which implements the IStatusLog interface."""
541
542 - def getTestResults():
543 """Return a dictionary that maps test-name tuples to ITestResult 544 objects. This may return an empty or partially-filled dictionary 545 until the build has completed."""
546 547 # subscription interface 548
549 - def subscribe(receiver, updateInterval=None):
550 """Register an IStatusReceiver to receive new status events. The 551 receiver will be given stepStarted and stepFinished messages. If 552 'updateInterval' is non-None, buildETAUpdate messages will be sent 553 every 'updateInterval' seconds."""
554
555 - def unsubscribe(receiver):
556 """Unregister an IStatusReceiver. No further status messgaes will be 557 delivered."""
558
559 -class ITestResult(Interface):
560 """I describe the results of a single unit test.""" 561
562 - def getName():
563 """Returns a tuple of strings which make up the test name. Tests may 564 be arranged in a hierarchy, so looking for common prefixes may be 565 useful."""
566
567 - def getResults():
568 """Returns a constant describing the results of the test: SUCCESS, 569 WARNINGS, FAILURE."""
570
571 - def getText():
572 """Returns a list of short strings which describe the results of the 573 test in slightly more detail. Suggested components include 574 'failure', 'error', 'passed', 'timeout'."""
575
576 - def getLogs():
577 # in flux, it may be possible to provide more structured information 578 # like python Failure instances 579 """Returns a dictionary of test logs. The keys are strings like 580 'stdout', 'log', 'exceptions'. The values are strings."""
581 582
583 -class IBuildStepStatus(Interface):
584 """I hold status for a single BuildStep.""" 585
586 - def getName():
587 """Returns a short string with the name of this step. This string 588 may have spaces in it."""
589
590 - def getBuild():
591 """Returns the IBuildStatus object which contains this step."""
592
593 - def getTimes():
594 """Returns a tuple of (start, end). 'start' and 'end' are the times 595 (seconds since the epoch) when the Step started and finished. If the 596 step has not yet started, 'start' will be None. If the step is still 597 running, 'end' will be None."""
598
599 - def getExpectations():
600 """Returns a list of tuples (name, current, target). Each tuple 601 describes a single axis along which the step's progress can be 602 measured. 'name' is a string which describes the axis itself, like 603 'filesCompiled' or 'tests run' or 'bytes of output'. 'current' is a 604 number with the progress made so far, while 'target' is the value 605 that we expect (based upon past experience) to get to when the build 606 is finished. 607 608 'current' will change over time until the step is finished. It is 609 'None' until the step starts. When the build is finished, 'current' 610 may or may not equal 'target' (which is merely the expectation based 611 upon previous builds)."""
612
613 - def getURLs():
614 """Returns a dictionary of URLs. Each key is a link name (a short 615 string, like 'results' or 'coverage'), and each value is a URL. These 616 links will be displayed along with the LogFiles. 617 """
618
619 - def getLogs():
620 """Returns a list of IStatusLog objects. If the step has not yet 621 finished, this list may be incomplete (asking again later may give 622 you more of them)."""
623 624
625 - def isFinished():
626 """Return a boolean. True means the step has finished, False means it 627 is still running."""
628
629 - def waitUntilFinished():
630 """Return a Deferred that will fire when the step finishes. If the 631 step has already finished, this deferred will fire right away. The 632 callback is given this IBuildStepStatus instance as an argument."""
633 634 # while the step is running, the following methods make sense. 635 # Afterwards they return None 636
637 - def getETA():
638 """Returns the number of seconds from now in which the step is 639 expected to finish, or None if we can't make a guess. This guess will 640 be refined over time."""
641 642 # Once you know the step has finished, the following methods are legal. 643 # Before ths step has finished, they all return None. 644
645 - def getText():
646 """Returns a list of strings which describe the step. These are 647 intended to be displayed in a narrow column. If more space is 648 available, the caller should join them together with spaces before 649 presenting them to the user."""
650
651 - def getResults():
652 """Return a tuple describing the results of the step: (result, 653 strings). 'result' is one of the constants in 654 buildbot.status.builder: SUCCESS, WARNINGS, FAILURE, or SKIPPED. 655 'strings' is an optional list of strings that the step wants to 656 append to the overall build's results. These strings are usually 657 more terse than the ones returned by getText(): in particular, 658 successful Steps do not usually contribute any text to the overall 659 build."""
660 661 # subscription interface 662
663 - def subscribe(receiver, updateInterval=10):
664 """Register an IStatusReceiver to receive new status events. The 665 receiver will be given logStarted and logFinished messages. It will 666 also be given a ETAUpdate message every 'updateInterval' seconds."""
667
668 - def unsubscribe(receiver):
669 """Unregister an IStatusReceiver. No further status messgaes will be 670 delivered."""
671
672 -class IStatusEvent(Interface):
673 """I represent a Builder Event, something non-Build related that can 674 happen to a Builder.""" 675
676 - def getTimes():
677 """Returns a tuple of (start, end) like IBuildStepStatus, but end==0 678 indicates that this is a 'point event', which has no duration. 679 SlaveConnect/Disconnect are point events. Ping is not: it starts 680 when requested and ends when the response (positive or negative) is 681 returned"""
682
683 - def getText():
684 """Returns a list of strings which describe the event. These are 685 intended to be displayed in a narrow column. If more space is 686 available, the caller should join them together with spaces before 687 presenting them to the user."""
688 689 690 LOG_CHANNEL_STDOUT = 0 691 LOG_CHANNEL_STDERR = 1 692 LOG_CHANNEL_HEADER = 2 693
694 -class IStatusLog(Interface):
695 """I represent a single Log, which is a growing list of text items that 696 contains some kind of output for a single BuildStep. I might be finished, 697 in which case this list has stopped growing. 698 699 Each Log has a name, usually something boring like 'log' or 'output'. 700 These names are not guaranteed to be unique, however they are usually 701 chosen to be useful within the scope of a single step (i.e. the Compile 702 step might produce both 'log' and 'warnings'). The name may also have 703 spaces. If you want something more globally meaningful, at least within a 704 given Build, try:: 705 706 '%s.%s' % (log.getStep.getName(), log.getName()) 707 708 The Log can be presented as plain text, or it can be accessed as a list 709 of items, each of which has a channel indicator (header, stdout, stderr) 710 and a text chunk. An HTML display might represent the interleaved 711 channels with different styles, while a straight download-the-text 712 interface would just want to retrieve a big string. 713 714 The 'header' channel is used by ShellCommands to prepend a note about 715 which command is about to be run ('running command FOO in directory 716 DIR'), and append another note giving the exit code of the process. 717 718 Logs can be streaming: if the Log has not yet finished, you can 719 subscribe to receive new chunks as they are added. 720 721 A ShellCommand will have a Log associated with it that gathers stdout 722 and stderr. Logs may also be created by parsing command output or 723 through other synthetic means (grepping for all the warnings in a 724 compile log, or listing all the test cases that are going to be run). 725 Such synthetic Logs are usually finished as soon as they are created.""" 726 727
728 - def getName():
729 """Returns a short string with the name of this log, probably 'log'. 730 """
731
732 - def getStep():
733 """Returns the IBuildStepStatus which owns this log."""
734 # TODO: can there be non-Step logs? 735
736 - def isFinished():
737 """Return a boolean. True means the log has finished and is closed, 738 False means it is still open and new chunks may be added to it."""
739
740 - def waitUntilFinished():
741 """Return a Deferred that will fire when the log is closed. If the 742 log has already finished, this deferred will fire right away. The 743 callback is given this IStatusLog instance as an argument."""
744
745 - def subscribe(receiver, catchup):
746 """Register an IStatusReceiver to receive chunks (with logChunk) as 747 data is added to the Log. If you use this, you will also want to use 748 waitUntilFinished to find out when the listener can be retired. 749 Subscribing to a closed Log is a no-op. 750 751 If 'catchup' is True, the receiver will immediately be sent a series 752 of logChunk messages to bring it up to date with the partially-filled 753 log. This allows a status client to join a Log already in progress 754 without missing any data. If the Log has already finished, it is too 755 late to catch up: just do getText() instead. 756 757 If the Log is very large, the receiver will be called many times with 758 a lot of data. There is no way to throttle this data. If the receiver 759 is planning on sending the data on to somewhere else, over a narrow 760 connection, you can get a throttleable subscription by using 761 C{subscribeConsumer} instead."""
762
763 - def unsubscribe(receiver):
764 """Remove a receiver previously registered with subscribe(). Attempts 765 to remove a receiver which was not previously registered is a no-op. 766 """
767
768 - def subscribeConsumer(consumer):
769 """Register an L{IStatusLogConsumer} to receive all chunks of the 770 logfile, including all the old entries and any that will arrive in 771 the future. The consumer will first have their C{registerProducer} 772 method invoked with a reference to an object that can be told 773 C{pauseProducing}, C{resumeProducing}, and C{stopProducing}. Then the 774 consumer's C{writeChunk} method will be called repeatedly with each 775 (channel, text) tuple in the log, starting with the very first. The 776 consumer will be notified with C{finish} when the log has been 777 exhausted (which can only happen when the log is finished). Note that 778 a small amount of data could be written via C{writeChunk} even after 779 C{pauseProducing} has been called. 780 781 To unsubscribe the consumer, use C{producer.stopProducing}."""
782 783 # once the log has finished, the following methods make sense. They can 784 # be called earlier, but they will only return the contents of the log up 785 # to the point at which they were called. You will lose items that are 786 # added later. Use C{subscribe} or C{subscribeConsumer} to avoid missing 787 # anything. 788
789 - def hasContents():
790 """Returns True if the LogFile still has contents available. Returns 791 False for logs that have been pruned. Clients should test this before 792 offering to show the contents of any log."""
793
794 - def getText():
795 """Return one big string with the contents of the Log. This merges 796 all non-header chunks together."""
797
798 - def readlines(channel=LOG_CHANNEL_STDOUT):
799 """Read lines from one channel of the logfile. This returns an 800 iterator that will provide single lines of text (including the 801 trailing newline). 802 """
803
804 - def getTextWithHeaders():
805 """Return one big string with the contents of the Log. This merges 806 all chunks (including headers) together."""
807
808 - def getChunks():
809 """Generate a list of (channel, text) tuples. 'channel' is a number, 810 0 for stdout, 1 for stderr, 2 for header. (note that stderr is merged 811 into stdout if PTYs are in use)."""
812
813 -class IStatusLogConsumer(Interface):
814 """I am an object which can be passed to IStatusLog.subscribeConsumer(). 815 I represent a target for writing the contents of an IStatusLog. This 816 differs from a regular IStatusReceiver in that it can pause the producer. 817 This makes it more suitable for use in streaming data over network 818 sockets, such as an HTTP request. Note that the consumer can only pause 819 the producer until it has caught up with all the old data. After that 820 point, C{pauseProducing} is ignored and all new output from the log is 821 sent directoy to the consumer.""" 822
823 - def registerProducer(producer, streaming):
824 """A producer is being hooked up to this consumer. The consumer only 825 has to handle a single producer. It should send .pauseProducing and 826 .resumeProducing messages to the producer when it wants to stop or 827 resume the flow of data. 'streaming' will be set to True because the 828 producer is always a PushProducer. 829 """
830
831 - def unregisterProducer():
832 """The previously-registered producer has been removed. No further 833 pauseProducing or resumeProducing calls should be made. The consumer 834 should delete its reference to the Producer so it can be released."""
835
836 - def writeChunk(chunk):
837 """A chunk (i.e. a tuple of (channel, text)) is being written to the 838 consumer."""
839
840 - def finish():
841 """The log has finished sending chunks to the consumer."""
842
843 -class IStatusReceiver(Interface):
844 """I am an object which can receive build status updates. I may be 845 subscribed to an IStatus, an IBuilderStatus, or an IBuildStatus.""" 846
847 - def buildsetSubmitted(buildset):
848 """A new BuildSet has been submitted to the buildmaster. 849 850 @type buildset: implementor of L{IBuildSetStatus} 851 """
852
853 - def requestSubmitted(request):
854 """A new BuildRequest has been submitted to the buildmaster. 855 856 @type request: implementor of L{IBuildRequestStatus} 857 """
858
859 - def requestCancelled(builder, request):
860 """A BuildRequest has been cancelled on the given Builder. 861 862 @type builder: L{buildbot.status.builder.BuilderStatus} 863 @type request: implementor of L{IBuildRequestStatus} 864 """
865
866 - def builderAdded(builderName, builder):
867 """ 868 A new Builder has just been added. This method may return an 869 IStatusReceiver (probably 'self') which will be subscribed to receive 870 builderChangedState and buildStarted/Finished events. 871 872 @type builderName: string 873 @type builder: L{buildbot.status.builder.BuilderStatus} 874 @rtype: implementor of L{IStatusReceiver} 875 """
876
877 - def builderChangedState(builderName, state):
878 """Builder 'builderName' has changed state. The possible values for 879 'state' are 'offline', 'idle', and 'building'."""
880
881 - def buildStarted(builderName, build):
882 """Builder 'builderName' has just started a build. The build is an 883 object which implements IBuildStatus, and can be queried for more 884 information. 885 886 This method may return an IStatusReceiver (it could even return 887 'self'). If it does so, stepStarted and stepFinished methods will be 888 invoked on the object for the steps of this one build. This is a 889 convenient way to subscribe to all build steps without missing any. 890 This receiver will automatically be unsubscribed when the build 891 finishes. 892 893 It can also return a tuple of (IStatusReceiver, interval), in which 894 case buildETAUpdate messages are sent ever 'interval' seconds, in 895 addition to the stepStarted and stepFinished messages."""
896
897 - def buildETAUpdate(build, ETA):
898 """This is a periodic update on the progress this Build has made 899 towards completion."""
900
901 - def changeAdded(change):
902 """A new Change was added to the ChangeMaster. By the time this event 903 is received, all schedulers have already received the change."""
904
905 - def stepStarted(build, step):
906 """A step has just started. 'step' is the IBuildStepStatus which 907 represents the step: it can be queried for more information. 908 909 This method may return an IStatusReceiver (it could even return 910 'self'). If it does so, logStarted and logFinished methods will be 911 invoked on the object for logs created by this one step. This 912 receiver will be automatically unsubscribed when the step finishes. 913 914 Alternatively, the method may return a tuple of an IStatusReceiver 915 and an integer named 'updateInterval'. In addition to 916 logStarted/logFinished messages, it will also receive stepETAUpdate 917 messages about every updateInterval seconds."""
918
919 - def stepTextChanged(build, step, text):
920 """The text for a step has been updated. 921 922 This is called when calling setText() on the step status, and 923 hands in the text list."""
924
925 - def stepText2Changed(build, step, text2):
926 """The text2 for a step has been updated. 927 928 This is called when calling setText2() on the step status, and 929 hands in text2 list."""
930
931 - def stepETAUpdate(build, step, ETA, expectations):
932 """This is a periodic update on the progress this Step has made 933 towards completion. It gets an ETA (in seconds from the present) of 934 when the step ought to be complete, and a list of expectation tuples 935 (as returned by IBuildStepStatus.getExpectations) with more detailed 936 information."""
937
938 - def logStarted(build, step, log):
939 """A new Log has been started, probably because a step has just 940 started running a shell command. 'log' is the IStatusLog object 941 which can be queried for more information. 942 943 This method may return an IStatusReceiver (such as 'self'), in which 944 case the target's logChunk method will be invoked as text is added to 945 the logfile. This receiver will automatically be unsubsribed when the 946 log finishes."""
947
948 - def logChunk(build, step, log, channel, text):
949 """Some text has been added to this log. 'channel' is one of 950 LOG_CHANNEL_STDOUT, LOG_CHANNEL_STDERR, or LOG_CHANNEL_HEADER, as 951 defined in IStatusLog.getChunks."""
952
953 - def logFinished(build, step, log):
954 """A Log has been closed."""
955
956 - def stepFinished(build, step, results):
957 """A step has just finished. 'results' is the result tuple described 958 in IBuildStepStatus.getResults."""
959
960 - def buildFinished(builderName, build, results):
961 """ 962 A build has just finished. 'results' is the result tuple described 963 in L{IBuildStatus.getResults}. 964 965 @type builderName: string 966 @type build: L{buildbot.status.build.BuildStatus} 967 @type results: tuple 968 """
969
970 - def builderRemoved(builderName):
971 """The Builder has been removed."""
972
973 - def slaveConnected(slaveName):
974 """The slave has connected."""
975
976 - def slaveDisconnected(slaveName):
977 """The slave has disconnected."""
978
979 - def checkConfig(otherStatusReceivers):
980 """Verify that there are no other status receivers which conflict with 981 the current one. 982 983 @type otherStatusReceivers: A list of L{IStatusReceiver} objects which 984 will contain self. 985 """
986 987
988 -class IControl(Interface):
989 - def addChange(change):
990 """Add a change to the change queue, for analysis by schedulers."""
991
992 - def getBuilder(name):
993 """Retrieve the IBuilderControl object for the given Builder."""
994
995 -class IBuilderControl(Interface):
996 - def submitBuildRequest(ss, reason, props=None):
997 """Create a BuildRequest, which will eventually cause a build of the 998 given SourceStamp to be run on this builder. This returns a 999 BuildRequestStatus object via a Deferred, which can be used to keep 1000 track of the builds that are performed."""
1001
1002 - def rebuildBuild(buildStatus, reason="<rebuild, no reason given>"):
1003 """Rebuild something we've already built before. This submits a 1004 BuildRequest to our Builder using the same SourceStamp as the earlier 1005 build. This has no effect (but may eventually raise an exception) if 1006 this Build has not yet finished."""
1007
1009 """ 1010 Get a list of L{IBuildRequestControl} objects for this Builder. 1011 Each one corresponds to an unclaimed build request. 1012 1013 @returns: list of objects via Deferred 1014 """
1015
1016 - def getBuild(number):
1017 """Attempt to return an IBuildControl object for the given build. 1018 Returns None if no such object is available. This will only work for 1019 the build that is currently in progress: once the build finishes, 1020 there is nothing to control anymore."""
1021
1022 - def ping():
1023 """Attempt to contact the slave and see if it is still alive. This 1024 returns a Deferred which fires with either True (the slave is still 1025 alive) or False (the slave did not respond). As a side effect, adds an 1026 event to this builder's column in the waterfall display containing the 1027 results of the ping. Note that this may not fail for a long time, it is 1028 implemented in terms of the timeout on the underlying TCP connection."""
1029 # TODO: this ought to live in ISlaveControl, maybe with disconnect() 1030 # or something. However the event that is emitted is most useful in 1031 # the Builder column, so it kinda fits here too. 1032
1033 -class IBuildRequestControl(Interface):
1034 - def subscribe(observer):
1035 """Register a callable that will be invoked (with a single 1036 IBuildControl object) for each Build that is created to satisfy this 1037 request. There may be multiple Builds created in an attempt to handle 1038 the request: they may be interrupted by the user or abandoned due to 1039 a lost slave. The last Build (the one which actually gets to run to 1040 completion) is said to 'satisfy' the BuildRequest. The observer will 1041 be called once for each of these Builds, both old and new."""
1042 - def unsubscribe(observer):
1043 """Unregister the callable that was registered with subscribe()."""
1044 - def cancel():
1045 """Remove the build from the pending queue. Has no effect if the 1046 build has already been started."""
1047
1048 -class IBuildControl(Interface):
1049 - def getStatus():
1050 """Return an IBuildStatus object for the Build that I control."""
1051 - def stopBuild(reason="<no reason given>"):
1052 """Halt the build. This has no effect if the build has already 1053 finished."""
1054
1055 -class ILogFile(Interface):
1056 """This is the internal interface to a LogFile, used by the BuildStep to 1057 write data into the log. 1058 """
1059 - def addStdout(data):
1060 pass
1061 - def addStderr(data):
1062 pass
1063 - def addHeader(data):
1064 pass
1065 - def finish():
1066 """The process that is feeding the log file has finished, and no 1067 further data will be added. This closes the logfile."""
1068
1069 -class ILogObserver(Interface):
1070 """Objects which provide this interface can be used in a BuildStep to 1071 watch the output of a LogFile and parse it incrementally. 1072 """ 1073 1074 # internal methods
1075 - def setStep(step):
1076 pass
1077 - def setLog(log):
1078 pass
1079 1080 # methods called by the LogFile
1081 - def logChunk(build, step, log, channel, text):
1082 pass
1083
1084 -class IBuildSlave(Interface):
1085 # this is a marker interface for the BuildSlave class 1086 pass
1087
1088 -class ILatentBuildSlave(IBuildSlave):
1089 """A build slave that is not always running, but can run when requested. 1090 """ 1091 substantiated = Attribute('Substantiated', 1092 'Whether the latent build slave is currently ' 1093 'substantiated with a real instance.') 1094
1095 - def substantiate():
1096 """Request that the slave substantiate with a real instance. 1097 1098 Returns a deferred that will callback when a real instance has 1099 attached."""
1100 1101 # there is an insubstantiate too, but that is not used externally ATM. 1102
1103 - def buildStarted(sb):
1104 """Inform the latent build slave that a build has started. 1105 1106 @param sb: a L{LatentSlaveBuilder}. The sb is the one for whom the 1107 build finished. 1108 """
1109
1110 - def buildFinished(sb):
1111 """Inform the latent build slave that a build has finished. 1112 1113 @param sb: a L{LatentSlaveBuilder}. The sb is the one for whom the 1114 build finished. 1115 """
1116
1117 -class IRenderable(Interface):
1118 """An object that can be interpolated with properties from a build. 1119 """ 1120
1121 - def getRenderingFor(iprops):
1122 """Return a deferred that fires with interpolation with the given properties 1123 1124 @param iprops: the L{IProperties} provider supplying the properties. 1125 """
1126 -class IProperties(Interface):
1127 """ 1128 An object providing access to build properties 1129 """ 1130
1131 - def getProperty(name, default=None):
1132 """Get the named property, returning the default if the property does 1133 not exist. 1134 1135 @param name: property name 1136 @type name: string 1137 1138 @param default: default value (default: @code{None}) 1139 1140 @returns: property value 1141 """
1142
1143 - def hasProperty(name):
1144 """Return true if the named property exists. 1145 1146 @param name: property name 1147 @type name: string 1148 @returns: boolean 1149 """
1150
1151 - def has_key(name):
1152 """Deprecated name for L{hasProperty}."""
1153
1154 - def setProperty(name, value, source, runtime=False):
1155 """Set the given property, overwriting any existing value. The source 1156 describes the source of the value for human interpretation. 1157 1158 @param name: property name 1159 @type name: string 1160 1161 @param value: property value 1162 @type value: JSON-able value 1163 1164 @param source: property source 1165 @type source: string 1166 1167 @param runtime: (optional) whether this property was set during the 1168 build's runtime: usually left at its default value 1169 @type runtime: boolean 1170 """
1171
1172 - def getProperties():
1173 """Get the L{buildbot.process.properties.Properties} instance storing 1174 these properties. Note that the interface for this class is not 1175 stable, so where possible the other methods of this interface should be 1176 used. 1177 1178 @returns: L{buildbot.process.properties.Properties} instance 1179 """
1180
1181 - def getBuild():
1182 """Get the L{buildbot.process.build.Build} instance for the current 1183 build. Note that this object is not available after the build is 1184 complete, at which point this method will return None. 1185 1186 Try to avoid using this method, as the API of L{Build} instances is not 1187 well-defined. 1188 1189 @returns L{buildbot.process.build.Build} instance 1190 """
1191
1192 - def render(value):
1193 """Render @code{value} as an L{IRenderable}. This essentially coerces 1194 @code{value} to an L{IRenderable} and calls its @L{getRenderingFor} 1195 method. 1196 1197 @name value: value to render 1198 @returns: rendered value 1199 """
1200
1201 -class IScheduler(Interface):
1202 pass
1203
1204 -class ITriggerableScheduler(Interface):
1205 """ 1206 A scheduler that can be triggered by buildsteps. 1207 """ 1208
1209 - def trigger(sourcestamps, set_props=None):
1210 """Trigger a build with the given source stamp and properties. 1211 """
1212
1213 -class IBuildStepFactory(Interface):
1214 - def buildStep():
1215 """ 1216 """
1217