[pypy-svn] buildbot default: send irc messages through kenaan

antocuni commits-noreply at bitbucket.org
Fri Jan 7 18:00:37 CET 2011


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: 
Changeset: r397:8211c56fcbd1
Date: 2011-01-07 17:29 +0100
http://bitbucket.org/pypy/buildbot/changeset/8211c56fcbd1/

Log:	send irc messages through kenaan

diff --git a/bitbucket_hook/hook.py b/bitbucket_hook/hook.py
--- a/bitbucket_hook/hook.py
+++ b/bitbucket_hook/hook.py
@@ -10,11 +10,17 @@
     SMTP_SERVER = "out.alice.it"
     SMTP_PORT = 25
     ADDRESS = 'anto.cuni at gmail.com'
+    #
+    CHANNEL = '#test'
+    BOT = '/tmp/commit-bot/message'
 else:
     # real settings, (they works on codespeak at least)
     SMTP_SERVER = 'localhost'
     SMTP_PORT = 25
     ADDRESS = 'pypy-svn at codespeak.net'
+    #
+    CHANNEL = '#pypy'
+    BOT = '/svn/hooks/commit-bot/message'
 
 hgexe = str(py.path.local.sysfind('hg'))
 
@@ -58,6 +64,10 @@
         msg['Subject'] = subject
         smtp.sendmail(from_, [to], msg.as_string())
 
+    def send_irc_message(self, message):
+        import subprocess
+        return subprocess.call([BOT, CHANNEL, message])
+
     def handle(self, payload):
         path = payload['repository']['absolute_url']
         self.payload = payload
@@ -67,8 +77,18 @@
             print >> sys.stderr, 'Ignoring unknown repo', path
             return
         self.hg('pull', '-R', self.local_repo)
+        self.handle_irc_message()
         self.handle_diff_email()
 
+    def handle_irc_message(self):
+        import operator
+        commits = sorted(self.payload['commits'],
+                         key=operator.itemgetter('revision'))
+        for commit in commits:
+            message = commit['message']
+            irc_msg = '%s %s: %s' % (commit['author'], commit['node'], message)
+            self.send_irc_message(irc_msg)
+
     def handle_diff_email(self):
         import operator
         commits = sorted(self.payload['commits'],

diff --git a/bitbucket_hook/test/test_hook.py b/bitbucket_hook/test/test_hook.py
--- a/bitbucket_hook/test/test_hook.py
+++ b/bitbucket_hook/test/test_hook.py
@@ -37,7 +37,6 @@
             self.sent_commits = []
         def send_diff_for_commit(self, commit):
             self.sent_commits.append(commit['node'])
-
     #
     handler = MyHandler()
     handler.payload = {
@@ -46,3 +45,20 @@
         }
     handler.handle_diff_email()
     assert handler.sent_commits == ['first', 'second']
+
+class test_irc_message():
+    class MyHandler(BaseHandler):
+        def __init__(self):
+            self.messages = []
+        def send_irc_message(self, message):
+            self.messages.append(message)
+    handler = MyHandler()
+    handler.payload = {
+        'commits': [{'revision': 42,
+                     'author': u'antocuni',
+                     'message': u'this is a test',
+                     'node': 'abcdef'
+                     }]
+        }
+    handler.handle_irc_message()
+    assert handler.messages == ['antocuni abcdef: this is a test']


More information about the Pypy-commit mailing list