fitnesse - find disabled tests

Thursday, September 23, 2010

FitNesse suites can grow enormous, so managing them becomes tough. Here's a simple script to find all pages in a given suite that are not marked as either a Test or as a Suite:


#! /bin/bash

if [ $# -eq 0 ]; then
echo "Shows fitnesse tests that aren't enabled as either Test or Suite"
echo 'Usage: ./find_disabled_tests.sh {parent_dir}'
echo 'Eg: ./find_disabled_tests.sh /var/local/fitnesse/FitNesseRoot/SitTests/RichTests'
exit 0
fi


cd $1

find -name properties.xml -print | xargs egrep -L '(Test/|true|Suite/|true)' | sed -e 's,/properties.xml,,'

python stdio in osx launchd

Monday, August 16, 2010

Running Python scripts via launchd doesn't seem to flush stdout print statements (ie. using the basic 'print' command). This can be confirmed by importing sys and calling sys.stdout.flush() after the print statements to see them actually output.

The solution? Add the -u flag to tell python not to buffer its stdio.

In an OSX launchd plist file, your solution may include:


<key>ProgramArguments</key>
<array>
<string>/usr/bin/python</string>
<string>-u</string>

use old laptop as monitor and terminal

Monday, May 31, 2010

I have just had a new Mac Mini arrive that I want to use for mostly automated and headless tasks. But I also want to use this as a home computer for my wife, but it has no screen and no mic, plus not much room on the bench where it lives to fit a keyboard and mouse. My wife has a decrepit (no battery; no harddrive) laptop she's been using, so hey, why not use that as a terminal?

Laptop is running puppy linux (4.3.1). Great little lightweight distro. It boots off CD and uses a USB key for storage.
- Installed tightvnc-client
Mac is running Snow Leopard

So by setting up the script below as a menu option (add to ~/.jwmrc), all she has to do is click it, and the connection begins, including sending all mic input sound (via dd with /dev/dsp) through an audio cable from laptop's headphone jack to Mac's input jack, registering as input on the Mac (Skype-ho!).

Beauty

[caveat: I cannot be held responsible for damage to hardware caused by plugging hardware into each other. Headphone jacks are pretty low voltage though, as I understand it, and it's worked for me]


#!/bin/sh

echo 'Hi, this is how to connect to the Mac Mini'
echo
echo 'Testing for network connection'
if ping -w 2 192.168.1.1 > /dev/null; then
echo ":) Found the router, we're connected already"
else
echo 'Here comes the Network Wizard to connect to the network. You know what to do...'
echo
echo -n 'Press enter once the network is done...'
net-setup.sh > /dev/null 2>&1
read resp
fi
echo
if ping -w 2 192.168.1.9 > /dev/null; then
echo ":) Mac is on, we're ready to connect"
else
echo 'Check the Mac is on. Look for the little white light on the front'
echo -n "Press enter when happy it's on. If only just turned on then wait a minute before continuing..."
read resp
fi
echo
if ps -ef | grep "[d]d if"; then
echo ':) Sound loopback for mic already running'
else
echo 'Ok, starting the sound loopback so we can send the mic to Mac'
dd if=/dev/dsp | dd of=/dev/dsp &
fi
echo
echo 'Right, about to start the connection'
echo "Enter '***' below as the password and you're good to go!"
echo

vncviewer 192.168.1.9:5900 -fullscreen

command line access to hosted JIRA files

Friday, May 28, 2010

Currently I'm on a project that uses an Atlassian-hosted JIRA Studio. We put scripts and config files as wiki page (confluence) attachments, then needed to access them from remote machines via the command line, even as part of a script. JIRA has it's own security methods, not simple http auth, which would be a piece of cake. So, another solution was needed.

A page in the JIRA Community Space describes how to do this using wget with cookies. But it didn't work for me. Whether this is because we are using the hosted variant, or due to changes since that page was written, I found we had to access a different url to log in.

So here's a current working solution that firstly interactively prompts for username and password to log in and creates a cookie:

echo -n "username: "; read uname; echo -n "password: "; stty -echo; read pass; stty echo; wget --save-cookies ~/jira_cookie.txt \
--post-data "os_username=$uname&os_password=$pass&os_cookie=true" -O /tmp/login 'http://OURDOMAIN.jira.com/rest/gadget/1.0/login'; uname=''; pass=''

Replace OURDOMAIN to make the url relevant for your site. This needs to be run only once per machine, at least until the cookie expires. The cookie file will be saved in your home dir.

Next, to retrieve any files, use:
echo -n "file url: "; read url; wget --load-cookies ~/jira_cookie.txt "$url"

Again replacing OURDOMAIN. Run this for each file, pasting the full url to the file to retrieve when prompted.

From these you should be able to see how to strip out the interactivity to make them scriptable, too.