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

Source Code for Module buildbot.clients.sendchange

 1   
 2  from twisted.spread import pb 
 3  from twisted.cred import credentials 
 4  from twisted.internet import reactor 
 5   
6 -class Sender:
7 - def __init__(self, master, user=None):
8 self.user = user 9 self.host, self.port = master.split(":") 10 self.port = int(self.port) 11 self.num_changes = 0
12
13 - def send(self, branch, revision, comments, files, user=None, category=None, 14 when=None, properties={}, repository='', project='', revlink=''):
15 if user is None: 16 user = self.user 17 change = {'project': project, 'repository': repository, 'who': user, 18 'files': files, 'comments': comments, 'branch': branch, 19 'revision': revision, 'category': category, 'when': when, 20 'properties': properties, 'revlink': revlink} 21 self.num_changes += 1 22 23 f = pb.PBClientFactory() 24 d = f.login(credentials.UsernamePassword("change", "changepw")) 25 reactor.connectTCP(self.host, self.port, f) 26 d.addCallback(self.addChange, change) 27 return d
28
29 - def addChange(self, remote, change):
30 d = remote.callRemote('addChange', change) 31 d.addCallback(lambda res: remote.broker.transport.loseConnection()) 32 return d
33
34 - def printSuccess(self, res):
35 if self.num_changes > 1: 36 print "%d changes sent successfully" % self.num_changes 37 elif self.num_changes == 1: 38 print "change sent successfully" 39 else: 40 print "no changes to send"
41
42 - def printFailure(self, why):
43 print "change(s) NOT sent, something went wrong:" 44 print why
45
46 - def stop(self, res):
47 reactor.stop() 48 return res
49
50 - def run(self):
51 reactor.run()
52