summaryrefslogtreecommitdiffstats
path: root/filter-test.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 14:27:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 14:27:58 +0000
commit3aecc6d0a8d757d6159dfa5083f1b254296c5b43 (patch)
tree3a305eb312ed47a1ac8967170ea1d45bb3c208be /filter-test.py
parentInitial commit. (diff)
downloadirker-3aecc6d0a8d757d6159dfa5083f1b254296c5b43.tar.xz
irker-3aecc6d0a8d757d6159dfa5083f1b254296c5b43.zip
Adding upstream version 2.23+dfsg.upstream/2.23+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'filter-test.py')
-rwxr-xr-xfilter-test.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/filter-test.py b/filter-test.py
new file mode 100755
index 0000000..9c42b71
--- /dev/null
+++ b/filter-test.py
@@ -0,0 +1,35 @@
+#!/usr/bin/env python3
+#
+# 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. Intended to be used in the root
+# directory of the irker repo. Probably only of interest only to irker
+# developers
+#
+# To use this, set up irkerhook.py to fire on each commit. Creating a
+# .git/hooks/post-commit file containing the line "irkerhook.py"; be
+# sure to make the opos-commit file executable. Then set the
+# filtercmd variable in your repo config as follows:
+#
+# [irker]
+# filtercmd = filter-test.py
+
+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 irkerd_count:
+ sys.stderr.write("Using a running irker instance...\n")
+else:
+ sys.stderr.write("Launching a new irker instance...\n")
+ os.system("gnome-terminal --title 'irkerd' -e 'irkerd -d 2' &")
+
+time.sleep(1.5) # Avoid a race condition
+
+print json.dumps(metadata)
+# end