2 from twisted
.spread
import pb
3 from twisted
.cred
import credentials
4 from twisted
.internet
import reactor
7 def __init__(self
, master
, user
=None):
9 self
.host
, self
.port
= master
.split(":")
10 self
.port
= int(self
.port
)
13 def send(self
, branch
, revision
, comments
, files
, user
=None, category
=None, when
=None):
16 change
= {'who': user
, 'files': files
, 'comments': comments
,
17 'branch': branch
, 'revision': revision
, 'category': category
,
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
)
27 def addChange(self
, remote
, change
):
28 d
= remote
.callRemote('addChange', change
)
29 d
.addCallback(lambda res
: remote
.broker
.transport
.loseConnection())
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"
38 print "no changes to send"
40 def printFailure(self
, why
):
41 print "change(s) NOT sent, something went wrong:"