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

Source Code for Module buildbot.clients.sendchange

 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  from twisted.spread import pb 
18  from twisted.cred import credentials 
19  from twisted.internet import reactor 
20   
21 -class Sender:
22 - def __init__(self, master, auth=('change','changepw')):
23 self.username, self.password = auth 24 self.host, self.port = master.split(":") 25 self.port = int(self.port) 26 self.num_changes = 0
27
28 - def send(self, branch, revision, comments, files, who=None, category=None, 29 when=None, properties={}, repository='', project='', revlink=''):
30 change = {'project': project, 'repository': repository, 'who': who, 31 'files': files, 'comments': comments, 'branch': branch, 32 'revision': revision, 'category': category, 'when': when, 33 'properties': properties, 'revlink': revlink} 34 self.num_changes += 1 35 36 f = pb.PBClientFactory() 37 d = f.login(credentials.UsernamePassword(self.username, self.password)) 38 reactor.connectTCP(self.host, self.port, f) 39 d.addCallback(self.addChange, change) 40 return d
41
42 - def addChange(self, remote, change):
43 d = remote.callRemote('addChange', change) 44 d.addCallback(lambda res: remote.broker.transport.loseConnection()) 45 return d
46
47 - def printSuccess(self, res):
48 if self.num_changes > 1: 49 print "%d changes sent successfully" % self.num_changes 50 elif self.num_changes == 1: 51 print "change sent successfully" 52 else: 53 print "no changes to send"
54
55 - def printFailure(self, why):
56 print "change(s) NOT sent, something went wrong:" 57 print why
58
59 - def stop(self, res):
60 reactor.stop() 61 return res
62
63 - def run(self):
64 reactor.run()
65