1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
21
24
29
32 self.lw.dataReceived(data)
34 print "ERR: '%s'" % (data,)
35
36
38 POLL_INTERVAL = 0.1
39 TIMEOUT_DELAY = 10.0
40 delimiter = os.linesep
41
49
51
52 if not os.path.exists(self.logfile):
53 open(self.logfile, 'a').close()
54
55
56
57
58
59
60 self.p = reactor.spawnProcess(self.pp, "/usr/bin/tail",
61 ("tail", "-f", "-n", "0", self.logfile),
62 env=os.environ,
63 )
64 self.running = True
65 d = defer.maybeDeferred(self._start)
66 return d
67
72
77
79 try:
80 self.p.signalProcess("KILL")
81 except error.ProcessExitedAlready:
82 pass
83 if self.timer:
84 self.timer.cancel()
85 self.timer = None
86 self.running = False
87 self.in_reconfig = False
88 self.d.callback(results)
89
91 if not self.running:
92 return
93 if "Log opened." in line:
94 self.in_reconfig = True
95 if "beginning configuration update" in line:
96 self.in_reconfig = True
97
98 if self.in_reconfig:
99 print line
100
101 if "message from master: attached" in line:
102 return self.finished("buildslave")
103 if "reconfig aborted" in line or 'reconfig partially applied' in line:
104 return self.finished(Failure(ReconfigError()))
105 if "Server Shut Down" in line:
106 return self.finished(Failure(ReconfigError()))
107 if "configuration update complete" in line:
108 return self.finished("buildmaster")
109 if "BuildMaster is running" in line:
110 return self.finished("buildmaster")
111