Trees | Indices | Help |
|
---|
|
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 17 import os 18 from twisted.python.failure import Failure 19 from twisted.internet import defer, reactor, protocol, error 20 from twisted.protocols.basic import LineOnlyReceiver 2123 disconnecting = False24 33 39 4042 POLL_INTERVAL = 0.1 43 TIMEOUT_DELAY = 10.0 44 delimiter = os.linesep 4511747 self.logfile = logfile 48 self.in_reconfig = False 49 self.transport = FakeTransport() 50 self.pp = TailProcess() 51 self.pp.lw = self 52 self.processtype = "buildmaster" 53 self.timer = None5456 # If the log file doesn't exist, create it now. 57 if not os.path.exists(self.logfile): 58 open(self.logfile, 'a').close() 59 60 # return a Deferred that fires when the reconfig process has 61 # finished. It errbacks with TimeoutError if the finish line has not 62 # been seen within 10 seconds, and with ReconfigError if the error 63 # line was seen. If the logfile could not be opened, it errbacks with 64 # an IOError. 65 self.p = reactor.spawnProcess(self.pp, "/usr/bin/tail", 66 ("tail", "-f", "-n", "0", self.logfile), 67 env=os.environ, 68 ) 69 self.running = True 70 d = defer.maybeDeferred(self._start) 71 return d7274 self.d = defer.Deferred() 75 self.timer = reactor.callLater(self.TIMEOUT_DELAY, self.timeout) 76 return self.d7779 self.timer = None 80 if self.processtype == "buildmaster": 81 e = BuildmasterTimeoutError() 82 else: 83 e = BuildslaveTimeoutError() 84 self.finished(Failure(e))8587 try: 88 self.p.signalProcess("KILL") 89 except error.ProcessExitedAlready: 90 pass 91 if self.timer: 92 self.timer.cancel() 93 self.timer = None 94 self.running = False 95 self.in_reconfig = False 96 self.d.callback(results)9799 if not self.running: 100 return 101 if "Log opened." in line: 102 self.in_reconfig = True 103 if "loading configuration from" in line: 104 self.in_reconfig = True 105 if "Creating BuildSlave" in line: 106 self.processtype = "buildslave" 107 108 if self.in_reconfig: 109 print line 110 111 if "message from master: attached" in line: 112 return self.finished("buildslave") 113 if "I will keep using the previous config file" in line: 114 return self.finished(Failure(ReconfigError())) 115 if "configuration update complete" in line: 116 return self.finished("buildmaster")
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Wed Nov 21 16:22:57 2012 | http://epydoc.sourceforge.net |