1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 import re
18
19 from twisted.spread import pb
20 from twisted.cred import credentials, error
21 from twisted.internet import reactor
22
24 """To use this, call my .connected method with a RemoteReference to the
25 buildmaster's StatusClientPerspective object.
26 """
27
29 self.builders = {}
30 self.events = events
31
33 print "connected"
34 self.remote = remote
35 remote.callRemote("subscribe", self.events, 5, self)
36
38 print "builderAdded", buildername
39
41 print "builderRemoved", buildername
42
44 print "builderChangedState", buildername, state, eta
45
47 print "buildStarted", buildername
48
51
53 print "ETA", buildername, eta
54
56 print "stepStarted", buildername, stepname
57
59 print "stepFinished", buildername, stepname, results
60
63 print "stepETA", buildername, stepname, eta
64
67 print "logStarted", buildername, stepname
68
71 print "logFinished", buildername, stepname
72
73 - def remote_logChunk(self, buildername, build, stepname, step, logname, log,
74 channel, text):
77
79 - def __init__(self, master, events="steps", username="statusClient", passwd="clientpw"):
80 """
81 @type master: string
82 @param master: a host:port string to masters L{buildbot.status.client.PBListener}
83
84 @type username: string
85 @param username:
86
87 @type passwd: string
88 @param passwd:
89
90 @type events: string, one of builders, builds, steps, logs, full
91 @param events: specify what level of detail should be reported.
92 - 'builders': only announce new/removed Builders
93 - 'builds': also announce builderChangedState, buildStarted, and
94 buildFinished
95 - 'steps': also announce buildETAUpdate, stepStarted, stepFinished
96 - 'logs': also announce stepETAUpdate, logStarted, logFinished
97 - 'full': also announce log contents
98 """
99 self.master = master
100 self.username = username
101 self.passwd = passwd
102 self.listener = StatusClient(events)
103
105 """Start the TextClient."""
106 self.startConnecting()
107 reactor.run()
108
109 - def startConnecting(self):
110 try:
111 host, port = re.search(r'(.+):(\d+)', self.master).groups()
112 port = int(port)
113 except:
114 print "unparseable master location '%s'" % self.master
115 print " expecting something more like localhost:8007"
116 raise
117 cf = pb.PBClientFactory()
118 creds = credentials.UsernamePassword(self.username, self.passwd)
119 d = cf.login(creds)
120 reactor.connectTCP(host, port, cf)
121 d.addCallbacks(self.connected, self.not_connected)
122 return d
123 - def connected(self, ref):
124 ref.notifyOnDisconnect(self.disconnected)
125 self.listener.connected(ref)
126 - def not_connected(self, why):
127 if why.check(error.UnauthorizedLogin):
128 print """
129 Unable to login.. are you sure we are connecting to a
130 buildbot.status.client.PBListener port and not to the slaveport?
131 """
132 reactor.stop()
133 return why
134 - def disconnected(self, ref):
135 print "lost connection"
136
137
138
139
140
141 try:
142 reactor.stop()
143 except RuntimeError:
144 pass
145