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 from buildbot.clients import base
23
25 - def __init__(self, master, events="steps", username="statusClient", passwd="clientpw"):
26 """
27 @type master: string
28 @param master: a host:port string to masters L{buildbot.status.client.PBListener}
29
30 @type username: string
31 @param username:
32
33 @type passwd: string
34 @param passwd:
35
36 @type events: string, one of builders, builds, steps, logs, full
37 @param events: specify what level of detail should be reported.
38 - 'builders': only announce new/removed Builders
39 - 'builds': also announce builderChangedState, buildStarted, and
40 buildFinished
41 - 'steps': also announce buildETAUpdate, stepStarted, stepFinished
42 - 'logs': also announce stepETAUpdate, logStarted, logFinished
43 - 'full': also announce log contents
44 """
45 self.master = master
46 self.username = username
47 self.passwd = passwd
48 self.listener = base.StatusClient(events)
49
51 """Start the TextClient."""
52 self.startConnecting()
53 reactor.run()
54
56 try:
57 host, port = re.search(r'(.+):(\d+)', self.master).groups()
58 port = int(port)
59 except:
60 print "unparseable master location '%s'" % self.master
61 print " expecting something more like localhost:8007"
62 raise
63 cf = pb.PBClientFactory()
64 creds = credentials.UsernamePassword(self.username, self.passwd)
65 d = cf.login(creds)
66 reactor.connectTCP(host, port, cf)
67 d.addCallbacks(self.connected, self.not_connected)
68 return d
69 - def connected(self, ref):
70 ref.notifyOnDisconnect(self.disconnected)
71 self.listener.connected(ref)
72 - def not_connected(self, why):
73 if why.check(error.UnauthorizedLogin):
74 print """
75 Unable to login.. are you sure we are connecting to a
76 buildbot.status.client.PBListener port and not to the slaveport?
77 """
78 reactor.stop()
79 return why
80 - def disconnected(self, ref):
81 print "lost connection"
82
83
84
85
86
87 try:
88 reactor.stop()
89 except RuntimeError:
90 pass
91