3 # Test hook to launch an irker instance (if it doesn't already exist)
4 # just before shipping the notification. We start it in in another terminal
5 # so you can watch the debug messages. Intended to be used in the root
6 # directory of the irker repo. Probably only of interest only to irker
9 # To use this, set up irkerhook.py to fire on each commit. Creating a
10 # .git/hooks/post-commit file containing the line "irkerhook.py"; be
11 # sure to make the opos-commit file executable. Then set the
12 # filtercmd variable in your repo config as follows:
15 # filtercmd = filter-test.py
17 import os, sys, json, subprocess, time
18 metadata = json.loads(sys.argv[1])
20 ps = subprocess.Popen("ps -U %s uh" % os.getenv("LOGNAME"),
22 stdout=subprocess.PIPE)
23 data = ps.stdout.read()
24 irkerd_count = len([x for x in data.split("\n") if x.find("irkerd") != -1])
27 sys.stderr.write("Using a running irker instance...\n")
29 sys.stderr.write("Launching a new irker instance...\n")
30 os.system("gnome-terminal --title 'irkerd' -e 'irkerd -d 2' &")
32 time.sleep(1.5) # Avoid a race condition
34 print json.dumps(metadata)