[pypy-svn] buildbot default: use color codes for irc messages

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


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

Log:	use color codes for irc messages

diff --git a/bitbucket_hook/hook.py b/bitbucket_hook/hook.py
--- a/bitbucket_hook/hook.py
+++ b/bitbucket_hook/hook.py
@@ -80,13 +80,21 @@
         self.handle_irc_message()
         self.handle_diff_email()
 
+    USE_COLOR_CODES = True
     def handle_irc_message(self):
         import operator
         commits = sorted(self.payload['commits'],
                          key=operator.itemgetter('revision'))
         for commit in commits:
+            author = commit['author']
+            branch = commit['branch']
+            node = commit['node']
+            if self.USE_COLOR_CODES:
+                author = '\x0312%s\x0F' % author   # in blue
+                branch = '\x02%s\x0F'   % branch   # in bold
+                node = '\x0311%s\x0F'   % node     # in azure
             message = commit['message'].replace('\n', ' ')
-            part1 = '%s %s %s: ' % (commit['author'], commit['branch'], commit['node'])
+            part1 = '%s %s %s: ' % (author, branch, node)
             if len(message) + len(part1) <= 160:
                 irc_msg = part1 + message
             else:

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
@@ -49,6 +49,7 @@
 def test_irc_message():
     LONG_MESSAGE = u'This is a test with a long message: ' + 'x'*1000
     class MyHandler(BaseHandler):
+        USE_COLOR_CODES = False
         def __init__(self):
             self.messages = []
         def send_irc_message(self, message):


More information about the Pypy-commit mailing list