From e553683b83be30ccc1564914843f032adaeae928 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 17 May 2013 10:01:37 -0400 Subject: [PATCH] Upgrade the test tool. --- hacking.txt | 2 +- irk | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/hacking.txt b/hacking.txt index c56f559..286bd2d 100644 --- a/hacking.txt +++ b/hacking.txt @@ -37,7 +37,7 @@ type switch. It can deduce the repo type by looking, so it should. 2. Do 'make pylint' to audit the code. -3. Run irkerd and irkerhook.py; look at #irker on freenode to verify. +3. Run irk with a sample message; look at #irker on freenode to verify. 4. Bump the version numbers in irkerd and irkerhook.py diff --git a/irk b/irk index 9a93c3f..4ca4a84 100755 --- a/irk +++ b/irk @@ -1,5 +1,6 @@ #!/usr/bin/env python -# Illustrates how to test irkerd. +# Illustrates how to test irkerd. Requires that the irkerd source +# be in the current directory. # # First argument must be a channel URL. If it does not begin with "irc", # the base URL for freenode is prepended. @@ -11,16 +12,29 @@ import json import socket import sys import fileinput +import subprocess +import time +import os def send(target, message): data = {"to": target, "privmsg" : message} - print(json.dumps(data)) + #print(json.dumps(data)) try: s = socket.create_connection(("localhost", 6659)) s.sendall(json.dumps(data)) except socket.error, e: sys.stderr.write("irkerd: write to server failed: %r\n" % e) +spawn = None +try: + # irkerd might already be running + s = socket.create_connection(("localhost", 6659)) +except: + # If it isn't, spawn an instance + print "Spawning an irker instance..." + subprocess.Popen("irkerd", shell=True) + time.sleep(0.5) + target = sys.argv[1] if not "irc:" in target: target = "irc://chat.freenode.net/{0}".format(target) -- 2.26.2