Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/buildbot/buildbot/clients/sendchange.py
diff options
context:
space:
mode:
Diffstat (limited to 'buildbot/buildbot/clients/sendchange.py')
-rw-r--r--buildbot/buildbot/clients/sendchange.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/buildbot/buildbot/clients/sendchange.py b/buildbot/buildbot/clients/sendchange.py
new file mode 100644
index 0000000..0ea4ba6
--- /dev/null
+++ b/buildbot/buildbot/clients/sendchange.py
@@ -0,0 +1,48 @@
+
+from twisted.spread import pb
+from twisted.cred import credentials
+from twisted.internet import reactor
+
+class Sender:
+ def __init__(self, master, user=None):
+ self.user = user
+ self.host, self.port = master.split(":")
+ self.port = int(self.port)
+ self.num_changes = 0
+
+ def send(self, branch, revision, comments, files, user=None, category=None):
+ if user is None:
+ user = self.user
+ change = {'who': user, 'files': files, 'comments': comments,
+ 'branch': branch, 'revision': revision, 'category': category}
+ self.num_changes += 1
+
+ f = pb.PBClientFactory()
+ d = f.login(credentials.UsernamePassword("change", "changepw"))
+ reactor.connectTCP(self.host, self.port, f)
+ d.addCallback(self.addChange, change)
+ return d
+
+ def addChange(self, remote, change):
+ d = remote.callRemote('addChange', change)
+ d.addCallback(lambda res: remote.broker.transport.loseConnection())
+ return d
+
+ def printSuccess(self, res):
+ if self.num_changes > 1:
+ print "%d changes sent successfully" % self.num_changes
+ elif self.num_changes == 1:
+ print "change sent successfully"
+ else:
+ print "no changes to send"
+
+ def printFailure(self, why):
+ print "change(s) NOT sent, something went wrong:"
+ print why
+
+ def stop(self, res):
+ reactor.stop()
+ return res
+
+ def run(self):
+ reactor.run()