Package buildbot :: Package clients :: Module text
[frames] | no frames]

Source Code for Module buildbot.clients.text

 1  # This file is part of Buildbot.  Buildbot is free software: you can 
 2  # redistribute it and/or modify it under the terms of the GNU General Public 
 3  # License as published by the Free Software Foundation, version 2. 
 4  # 
 5  # This program is distributed in the hope that it will be useful, but WITHOUT 
 6  # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
 7  # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
 8  # details. 
 9  # 
10  # You should have received a copy of the GNU General Public License along with 
11  # this program; if not, write to the Free Software Foundation, Inc., 51 
12  # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 
13  # 
14  # Copyright Buildbot Team Members 
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   
24 -class TextClient:
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
50 - def run(self):
51 """Start the TextClient.""" 52 self.startConnecting() 53 reactor.run()
54
55 - def startConnecting(self):
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 # we can get here in one of two ways: the buildmaster has 83 # disconnected us (probably because it shut itself down), or because 84 # we've been SIGINT'ed. In the latter case, our reactor is already 85 # shut down, but we have no easy way of detecting that. So protect 86 # our attempt to shut down the reactor. 87 try: 88 reactor.stop() 89 except RuntimeError: 90 pass
91