[pypy-svn] buildbot default: move the logging of received commits to a separate handler, and print it in green
antocuni
commits-noreply at bitbucket.org
Thu Apr 21 11:40:50 CEST 2011
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch:
Changeset: r492:81f970a9bbcc
Date: 2011-04-21 11:03 +0200
http://bitbucket.org/pypy/buildbot/changeset/81f970a9bbcc/
Log: move the logging of received commits to a separate handler, and
print it in green
diff --git a/bitbucket_hook/hook.py b/bitbucket_hook/hook.py
--- a/bitbucket_hook/hook.py
+++ b/bitbucket_hook/hook.py
@@ -4,13 +4,16 @@
import sys
import time
+from .main import app
+from . import scm
+#
+from . import stdoutlog
from . import irc
-from .main import app
-
-from . import scm
from . import mail
+
HANDLERS = [
+ stdoutlog.handle_commit,
irc.handle_commit,
mail.handle_commit
]
diff --git a/bitbucket_hook/irc.py b/bitbucket_hook/irc.py
--- a/bitbucket_hook/irc.py
+++ b/bitbucket_hook/irc.py
@@ -3,7 +3,6 @@
'''
import os
-import time
import subprocess
def getpaths(files, listfiles=False):
@@ -58,8 +57,6 @@
author = commit['author']
branch = commit['branch']
node = commit['node']
- timestamp = commit.get('timestamp')
- print time.strftime('[%Y-%m-%d %H:%M]'), node, timestamp, author
files = commit.get('files', [])
common_prefix, filenames = getpaths(files, app.config['LISTFILES'])
diff --git a/bitbucket_hook/stdoutlog.py b/bitbucket_hook/stdoutlog.py
new file mode 100644
--- /dev/null
+++ b/bitbucket_hook/stdoutlog.py
@@ -0,0 +1,21 @@
+import time
+
+RED = 31
+GREEN = 32
+YELLOW = 33
+BLUE = 34
+MAGENTA = 35
+CYAN = 36
+GRAY = 37
+
+def color(s, fg=1, bg=1):
+ template = '\033[%02d;%02dm%s\033[0m'
+ return template % (bg, fg, s)
+
+def handle_commit(payload, commit, test=False):
+ author = commit['author']
+ node = commit['node']
+ timestamp = commit.get('timestamp')
+ curtime = time.strftime('[%Y-%m-%d %H:%M]')
+ log = '%s %s %s %s' % (curtime, node, timestamp, author)
+ print color(log, fg=GREEN)
More information about the Pypy-commit
mailing list