[Buildbot-commits] buildbot/buildbot/scripts runner.py,1.34,1.35 tryclient.py,1.7,1.8

Brian Warner warner at users.sourceforge.net
Wed Aug 31 01:12:08 UTC 2005


Update of /cvsroot/buildbot/buildbot/buildbot/scripts
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9855/buildbot/scripts

Modified Files:
	runner.py tryclient.py 
Log Message:
Revision: arch at buildbot.sf.net--2004/buildbot--dev--0--patch-299
Creator:  Brian Warner <warner at lothar.com>

make jobdir-style 'try' report status properly

	* buildbot/scripts/tryclient.py (Try): make jobdir-style 'try'
	report status properly.
	* buildbot/status/client.py (StatusClientPerspective): add a
	perspective_getBuildSets method for the benefit of jobdir-style
	'try'.
	* docs/buildbot.texinfo (try): more docs
	* buildbot/test/test_scheduler.py (Scheduling.testGetBuildSets):
	new test case


Index: runner.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/scripts/runner.py,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- runner.py	15 Aug 2005 18:05:05 -0000	1.34
+++ runner.py	31 Aug 2005 01:12:06 -0000	1.35
@@ -610,6 +610,7 @@
         ]
 
 def doTryServer(config):
+    import md5
     jobdir = os.path.expanduser(config["jobdir"])
     job = sys.stdin.read()
     # now do a 'safecat'-style write to jobdir/tmp, then move atomically to

Index: tryclient.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/scripts/tryclient.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- tryclient.py	18 Aug 2005 08:30:01 -0000	1.7
+++ tryclient.py	31 Aug 2005 01:12:06 -0000	1.8
@@ -187,11 +187,54 @@
     def connectionMade(self):
         self.transport.write(self.job)
         self.transport.closeStdin()
+    def outReceived(self, data):
+        sys.stdout.write(data)
+    def errReceived(self, data):
+        sys.stderr.write(data)
     def processEnded(self, status_object):
         sig = status_object.value.signal
         rc = status_object.value.exitCode
+        if sig != None or rc != 0:
+            self.d.errback(RuntimeError("remote 'buildbot tryserver' failed"
+                                        ": sig=%s, rc=%s" % (sig, rc)))
+            return
         self.d.callback((sig, rc))
 
+class BuildSetStatusGrabber:
+    retryCount = 5 # how many times to we try to grab the BuildSetStatus?
+    retryDelay = 3 # seconds to wait between attempts
+
+    def __init__(self, status, bsid):
+        self.status = status
+        self.bsid = bsid
+
+    def grab(self):
+        # return a Deferred that either fires with the BuildSetStatus
+        # reference or errbacks because we were unable to grab it
+        self.d = defer.Deferred()
+        # wait a second before querying to give the master's maildir watcher
+        # a chance to see the job
+        reactor.callLater(1, self.go)
+        return self.d
+
+    def go(self, dummy=None):
+        if self.retryCount == 0:
+            raise RuntimeError("couldn't find matching buildset")
+        self.retryCount -= 1
+        d = self.status.callRemote("getBuildSets")
+        d.addCallback(self._gotSets)
+
+    def _gotSets(self, buildsets):
+        for bs,bsid in buildsets:
+            if bsid == self.bsid:
+                # got it
+                self.d.callback(bs)
+                return
+        d = defer.Deferred()
+        d.addCallback(self.go)
+        reactor.callLater(self.retryDelay, d.callback, None)
+
+
 class Try(pb.Referenceable):
     buildsetStatus = None
     quiet = False
@@ -241,7 +284,8 @@
         self.sourcestamp = ss
         if self.connect == "ssh":
             patchlevel, diff = ss.patch
-            self.jobfile = createJobfile(bsid, ss.branch or "", ss.revision,
+            self.jobfile = createJobfile(self.bsid,
+                                         ss.branch or "", ss.revision,
                                          patchlevel, diff,
                                          self.builderNames)
 
@@ -256,7 +300,7 @@
             trydir = self.getopt("trydir", "try_dir")
 
             argv = ["ssh", "-l", tryuser, tryhost,
-                    "buildbot", "tryserver", trydir]
+                    "buildbot", "tryserver", "--jobdir", trydir]
             # now run this command and feed the contents of 'job' into stdin
 
             pp = RemoteTryPP(self.jobfile)
@@ -294,14 +338,32 @@
         wait = bool(self.getopt("wait", "try_wait", False))
         if not wait:
             # TODO: emit the URL where they can follow the builds
+            print "not waiting for builds to finish"
             return
         d = self.running = defer.Deferred()
         if self.buildsetStatus:
             self._getStatus_1()
-        # TODO: contact the status port, acquire a remotereference to the
-        # corresponding BuildSetStatus object.
+        # contact the status port
+        # we're probably using the ssh style
+        master = self.getopt("master", "masterstatus")
+        host, port = master.split(":")
+        port = int(port)
+        self.announce("contacting the status port at %s:%d" % (host, port))
+        f = pb.PBClientFactory()
+        creds = credentials.UsernamePassword("statusClient", "clientpw")
+        d = f.login(creds)
+        reactor.connectTCP(host, port, f)
+        d.addCallback(self._getStatus_ssh_1)
+        return self.running
+
+    def _getStatus_ssh_1(self, remote):
+        # find a remotereference to the corresponding BuildSetStatus object
+        self.announce("waiting for job to be accepted")
+        g = BuildSetStatusGrabber(remote, self.bsid)
+        d = g.grab()
+        d.addCallback(self._getStatus_1)
         return d
-    
+
     def _getStatus_1(self, res=None):
         if res:
             self.buildsetStatus = res





More information about the Commits mailing list