Package buildbot :: Package clients :: Module sendchange
[hide private]
[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, when=None):
14 if user is None: 15 user = self.user 16 change = {'who': user, 'files': files, 'comments': comments, 17 'branch': branch, 'revision': revision, 'category': category, 18 'when': when} 19 self.num_changes += 1 20 21 f = pb.PBClientFactory() 22 d = f.login(credentials.UsernamePassword("change", "changepw")) 23 reactor.connectTCP(self.host, self.port, f) 24 d.addCallback(self.addChange, change) 25 return d
26
27 - def addChange(self, remote, change):
28 d = remote.callRemote('addChange', change) 29 d.addCallback(lambda res: remote.broker.transport.loseConnection()) 30 return d
31
32 - def printSuccess(self, res):
33 if self.num_changes > 1: 34 print "%d changes sent successfully" % self.num_changes 35 elif self.num_changes == 1: 36 print "change sent successfully" 37 else: 38 print "no changes to send"
39
40 - def printFailure(self, why):
41 print "change(s) NOT sent, something went wrong:" 42 print why
43
44 - def stop(self, res):
45 reactor.stop() 46 return res
47
48 - def run(self):
49 reactor.run()
50