[Buildbot-commits] buildbot/buildbot/scripts tryclient.py,1.8,1.9

Brian Warner warner at users.sourceforge.net
Wed Aug 31 01:51:27 UTC 2005


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

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

'try': implement unique buildset IDs, getTopdir for CVS/SVN

	* buildbot/scripts/tryclient.py (getTopdir): implement getTopdir
	for 'try' on CVS/SVN
	* buildbot/test/test_runner.py (Try.testGetTopdir): test case

	* buildbot/scripts/tryclient.py (Try.createJob): implement unique
	buildset IDs


Index: tryclient.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/scripts/tryclient.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- tryclient.py	31 Aug 2005 01:12:06 -0000	1.8
+++ tryclient.py	31 Aug 2005 01:51:25 -0000	1.9
@@ -1,6 +1,6 @@
 # -*- test-case-name: buildbot.test.test_scheduler,buildbot.test.test_vc -*-
 
-import sys, os, re, time
+import sys, os, re, time, random
 from twisted.internet import utils, protocol, defer, reactor, task
 from twisted.spread import pb
 from twisted.cred import credentials
@@ -174,11 +174,21 @@
     return job
 
 def getTopdir(topfile, start=None):
+    """walk upwards from the current directory until we find this topfile"""
     if not start:
         start = os.getcwd()
-    # TODO: now walk upwards from the current directory until we find this
-    # topfile
-    raise NotImplemented
+    here = start
+    toomany = 20
+    while toomany > 0:
+        if os.path.exists(os.path.join(here, topfile)):
+            return here
+        next = os.path.dirname(here)
+        if next == here:
+            break # we've hit the root
+        here = next
+        toomany -= 1
+    raise ValueError("Unable to find topfile '%s' anywhere from %s upwards"
+                     % (topfile, start))
 
 class RemoteTryPP(protocol.ProcessProtocol):
     def __init__(self, job):
@@ -261,7 +271,10 @@
         # created
         config = self.config
         opts = self.opts
-        self.bsid = "buildsetID" # TODO: generate a random (unique) string
+        # generate a random (unique) string. It would make sense to add a
+        # hostname and process ID here, but a) I suspect that would cause
+        # windows portability problems, and b) really this is good enough
+        self.bsid = "%d-%s" % (time.time(), random.randint(0, 1000000))
 
         # common options
         vc = self.getopt("vc", "try_vc")





More information about the Commits mailing list