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