[Buildbot-commits] buildbot/buildbot/steps trigger.py,1.2,1.3

Brian Warner warner at users.sourceforge.net
Fri Mar 21 01:32:02 UTC 2008


Update of /cvsroot/buildbot/buildbot/buildbot/steps
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv20526/buildbot/steps

Modified Files:
	trigger.py 
Log Message:
[project @ clean up scheduler.Triggerable and friends]

Original author: warner at lothar.com
Date: 2008-03-21 01:30:30+00:00

Index: trigger.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/steps/trigger.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- trigger.py	20 Mar 2008 19:06:27 -0000	1.2
+++ trigger.py	21 Mar 2008 01:32:00 -0000	1.3
@@ -4,41 +4,48 @@
 from twisted.internet import defer
 
 class Trigger(LoggingBuildStep):
-    """
-    I trigger a Triggerable.  It's fun.
+    """I trigger a scheduler.Triggerable, to use one or more Builders as if
+    they were a single buildstep (like a subroutine call).
     """
     name = "trigger"
 
     flunkOnFailure = True
 
-    def __init__(self,
-        schedulers=[],
-        updateSourceStamp=False,
-        waitForFinish=False,
-        **kwargs):
+    def __init__(self, schedulerNames=[], updateSourceStamp=True,
+                 waitForFinish=False, **kwargs):
         """
         Trigger the given schedulers when this step is executed.
 
-        @var schedulers: list of schedulers' names that should be triggered.  Schedulers
-        can be specified using WithProperties, if desired.
+        @param schedulerNames: A list of scheduler names that should be
+                               triggered. Schedulers can be specified using
+                               WithProperties, if desired.
 
-        @var updateSourceStamp: should I update the source stamp to
-        an absolute SourceStamp before triggering a new build?
+        @param updateSourceStamp: If True (the default), I will try to give
+                                  the schedulers an absolute SourceStamp for
+                                  their builds, so that a HEAD build will use
+                                  the same revision even if more changes have
+                                  occurred since my build's update step was
+                                  run. If False, I will use the original
+                                  SourceStamp unmodified.
 
-        @var waitForFinish: should I wait for all of the triggered schedulers to finish
-        their builds?
+        @param waitForFinish: If False (the default), this step will finish
+                              as soon as I've started the triggered
+                              schedulers. If True, I will wait until all of
+                              the triggered schedulers have finished their
+                              builds.
         """
-        assert schedulers, "You must specify a scheduler to trigger"
-        self.schedulers = schedulers
+        assert schedulerNames, "You must specify a scheduler to trigger"
+        self.schedulerNames = schedulerNames
         self.updateSourceStamp = updateSourceStamp
         self.waitForFinish = waitForFinish
         self.running = False
         LoggingBuildStep.__init__(self, **kwargs)
-        self.addFactoryArguments(schedulers=schedulers,
+        self.addFactoryArguments(schedulerNames=schedulerNames,
                                  updateSourceStamp=updateSourceStamp,
                                  waitForFinish=waitForFinish)
 
     def interrupt(self, reason):
+        # TODO: this doesn't actually do anything.
         if self.running:
             self.step_status.setColor("red")
             self.step_status.setText(["interrupted"])
@@ -47,15 +54,22 @@
         self.running = True
         ss = self.build.getSourceStamp()
         if self.updateSourceStamp:
-            ss = ss.getAbsoluteSourceStamp(self.build.getProperty('got_revision'))
+            got = None
+            try:
+                got = self.build.getProperty('got_revision')
+            except KeyError:
+                pass
+            if got:
+                ss = ss.getAbsoluteSourceStamp(got)
         # (is there an easier way to find the BuildMaster?)
         all_schedulers = self.build.builder.botmaster.parent.allSchedulers()
         all_schedulers = dict([(sch.name, sch) for sch in all_schedulers])
         unknown_schedulers = []
         triggered_schedulers = []
 
+        # TODO: don't fire any schedulers if we discover an unknown one
         dl = []
-        for scheduler in self.schedulers:
+        for scheduler in self.schedulerNames:
             if isinstance(scheduler, WithProperties):
                 scheduler = scheduler.render(self.build)
             if all_schedulers.has_key(scheduler):
@@ -85,6 +99,8 @@
         else:
             d = defer.succeed([])
 
+        # TODO: review this shadowed 'rc' value: can the callback modify the
+        # one that was defined above?
         def cb(rclist):
             rc = SUCCESS
             for was_cb, buildsetstatus in rclist:





More information about the Commits mailing list