1
2 import os
3 from twisted.python.failure import Failure
4 from twisted.internet import defer, reactor, protocol, error
5 from twisted.protocols.basic import LineOnlyReceiver
6
9
18
21 self.lw.dataReceived(data)
23 print "ERR: '%s'" % (data,)
24
25
27 POLL_INTERVAL = 0.1
28 TIMEOUT_DELAY = 10.0
29 delimiter = os.linesep
30
32 self.logfile = logfile
33 self.in_reconfig = False
34 self.transport = FakeTransport()
35 self.pp = TailProcess()
36 self.pp.lw = self
37 self.processtype = "buildmaster"
38 self.timer = None
39
41
42 if not os.path.exists(self.logfile):
43 open(self.logfile, 'a').close()
44
45
46
47
48
49
50 self.p = reactor.spawnProcess(self.pp, "/usr/bin/tail",
51 ("tail", "-f", "-n", "0", self.logfile),
52 env=os.environ,
53 )
54 self.running = True
55 d = defer.maybeDeferred(self._start)
56 return d
57
62
70
72 try:
73 self.p.signalProcess("KILL")
74 except error.ProcessExitedAlready:
75 pass
76 if self.timer:
77 self.timer.cancel()
78 self.timer = None
79 self.running = False
80 self.in_reconfig = False
81 self.d.callback(results)
82
84 if not self.running:
85 return
86 if "Log opened." in line:
87 self.in_reconfig = True
88 if "loading configuration from" in line:
89 self.in_reconfig = True
90 if "Creating BuildSlave" in line:
91 self.processtype = "buildslave"
92
93 if self.in_reconfig:
94 print line
95
96 if "message from master: attached" in line:
97 return self.finished("buildslave")
98 if "I will keep using the previous config file" in line:
99 return self.finished(Failure(ReconfigError()))
100 if "configuration update complete" in line:
101 return self.finished("buildmaster")
102