[Buildbot-commits] buildbot/buildbot scheduler.py,1.13,1.14 master.py,1.90,1.91

Brian Warner warner at users.sourceforge.net
Fri Jan 13 08:34:30 UTC 2006


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

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

all port= args now accept a strports string: slaveport, Waterfall, etc

	* buildbot/master.py (Manhole.__init__): let port= be a strports
	specification string, but handle a regular int for backwards
	compatibility. This allows "tcp:12345:interface=127.0.0.1" to be
	used in master.cfg to limit connections to just the local host.
	(BuildMaster.loadConfig): same for c['slavePortnum']
	* buildbot/scheduler.py (Try_Userpass.__init__): same
	* buildbot/status/client.py (PBListener.__init__): same
	* buildbot/status/html.py (Waterfall.__init__): same, for both
	http_port and distrib_port. Include backwards-compatibility checks
	so distrib_port can be a filename string and still mean unix:/foo
	* docs/buildbot.texinfo (Setting the slaveport): document it
	(Debug options): same
	(HTML Waterfall): same
	(PBListener): same
	(try): same
	* buildbot/test/test_config.py (ConfigTest): test it

	* buildbot/master.py (BuildMaster.loadConfig): wait for the
	slaveport's disownServiceParent deferred to fire before opening
	the new one. Fixes an annoying bug in the unit tests.


Index: master.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/master.py,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -d -r1.90 -r1.91
--- master.py	3 Jan 2006 09:26:40 -0000	1.90
+++ master.py	13 Jan 2006 08:34:28 -0000	1.91
@@ -15,7 +15,7 @@
 from twisted.internet import defer, reactor
 from twisted.spread import pb
 from twisted.cred import portal, checkers
-from twisted.application import service, internet
+from twisted.application import service, strports
 from twisted.persisted import styles
 from twisted.manhole import telnet
 
@@ -429,17 +429,19 @@
 
     def __init__(self, port, username, password):
         service.MultiService.__init__(self)
+        if type(port) is int:
+            port = "tcp:%d" % port
         self.port = port
         self.username = username
         self.password = password
         self.f = f = telnet.ShellFactory()
         f.username = username
         f.password = password
-        p = internet.TCPServer(port, f)
-        p.setServiceParent(self)
+        s = strports.service(port, f)
+        s.setServiceParent(self)
 
     def startService(self):
-        log.msg("Manhole listening on port %d" % self.port)
+        log.msg("Manhole listening on port %s" % self.port)
         service.MultiService.startService(self)
         master = self.parent
         self.f.namespace['master'] = master
@@ -809,6 +811,10 @@
                     else:
                         locks[l.name] = l
 
+        # slavePortnum supposed to be a strports specification
+        if type(slavePortnum) is int:
+            slavePortnum = "tcp:%d" % slavePortnum
+
         # now we're committed to implementing the new configuration, so do
         # it atomically
         # TODO: actually, this is spread across a couple of Deferreds, so it
@@ -855,17 +861,20 @@
         # self.slavePort
         if self.slavePortnum != slavePortnum:
             if self.slavePort:
-                d.addCallback(lambda res: self.slavePort.disownServiceParent())
-                self.slavePort = None
+                def closeSlavePort(res):
+                    d1 = self.slavePort.disownServiceParent()
+                    self.slavePort = None
+                    return d1
+                d.addCallback(closeSlavePort)
             if slavePortnum is not None:
                 def openSlavePort(res):
-                    self.slavePort = internet.TCPServer(slavePortnum,
-                                                        self.slaveFactory)
+                    self.slavePort = strports.service(slavePortnum,
+                                                      self.slaveFactory)
                     self.slavePort.setServiceParent(self)
                 d.addCallback(openSlavePort)
-                log.msg("BuildMaster listening on port %d" % slavePortnum)
+                log.msg("BuildMaster listening on port %s" % slavePortnum)
             self.slavePortnum = slavePortnum
-        
+
         log.msg("configuration update started")
         d.addCallback(lambda res: log.msg("configuration update complete"))
         self.readConfig = True # TODO: consider not setting this until the

Index: scheduler.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/scheduler.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- scheduler.py	3 Jan 2006 09:26:40 -0000	1.13
+++ scheduler.py	13 Jan 2006 08:34:28 -0000	1.14
@@ -3,7 +3,7 @@
 import time, os.path
 
 from twisted.internet import reactor
-from twisted.application import service, internet
+from twisted.application import service, internet, strports
 from twisted.python import log
 from twisted.protocols import basic
 from twisted.cred import portal, checkers
@@ -624,6 +624,8 @@
 
     def __init__(self, name, builderNames, port, userpass):
         TryBase.__init__(self, name, builderNames)
+        if type(port) is int:
+            port = "tcp:%d" % port
         self.port = port
         self.userpass = userpass
         c = checkers.InMemoryUsernamePasswordDatabaseDontUse()
@@ -633,7 +635,7 @@
         p = portal.Portal(self)
         p.registerChecker(c)
         f = pb.PBServerFactory(p)
-        s = internet.TCPServer(port, f)
+        s = strports.service(port, f)
         s.setServiceParent(self)
 
     def getPort(self):





More information about the Commits mailing list