From: Eric S. Raymond Date: Thu, 4 Oct 2012 10:08:13 +0000 (-0400) Subject: Add a useful test hook. X-Git-Tag: 1.7~22 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=5832b800350655830e54d3fd919c18d5451deef1;p=irker.git Add a useful test hook. --- diff --git a/Makefile b/Makefile index 8f12391..50fac43 100644 --- a/Makefile +++ b/Makefile @@ -46,7 +46,8 @@ loc: @echo -n "LLOC: "; grep -vE '(^ *#|^ *$$)' irkerd irkerhook.py | wc -l SOURCES = README COPYING NEWS install.txt security.txt hacking.txt \ - irkerd irkerhook.py filter-example.py Makefile irkerd.xml irkerhook.xml + irkerd irkerhook.py filter-example.py filter-test.py \ + Makefile irkerd.xml irkerhook.xml EXTRA_DIST = irker-logo.png org.catb.irkerd.plist version: diff --git a/filter-test.py b/filter-test.py new file mode 100755 index 0000000..ae91127 --- /dev/null +++ b/filter-test.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python +# +# Test hook to launch an irker instance (if it doesn't already exist) +# just before shipping the notification. We start it in in another terminal +# so you can watch the debug messages. Probably only of interest only to +# developers +# +# To use it, set up irkerhook.py to file on each commit. +# Then set the filtercmd variable in your repo config as follows: +# +# [irker] +# filtercmd = filter-test.py +# +# This is rather antisocial - imagine thousands of irkerds holding open +# connections to IRCDs. It's better to go through an instance running +# at your forge or set up for shared use by your intranet administrator. + +import os, sys, json, subprocess, time +metadata = json.loads(sys.argv[1]) + +ps = subprocess.Popen("ps -U %s uh" % os.getenv("LOGNAME"), + shell=True, + stdout=subprocess.PIPE) +data = ps.stdout.read() +irkerd_count = len([x for x in data.split("\n") if x.find("irkerd") != -1]) + +if not irkerd_count: + os.system("gnome-terminal --title 'irkerd' -e 'irkerd -d 2' &") + +time.sleep(0.1) # Avoid a race condition + +print json.dumps(metadata) +# end