Friday, January 23, 2009

My road-trip mix tape

Country Feedback by R.E.M.

This is the perfect REM song. It has dense imagery and a unique musical environment.

Round Here by Counting Crows

It's mellow, and one of my favorites. I love the guitar arpeggios.

Suddenly I See by KT Tunstall

I love the chorus in this song. I end up humming it for hours every time I hear it.

Saturday, January 10, 2009

Unit testing with Google App Engine

from Kensington, Greater London, UK
Tonight, I've been working on the unit testing framework for severedelays.org. I started out with a basic web search that lead me to this article, which suggested mocking out all of the framework calls. This sounded great, but was really too much work for me to reliably do on a regular basis.

What I really wanted was something I could run from my machine to make sure that my code was ok without having to manually run through all of the possible pages in my app.

Next I came to these suggestions by the App Engine team, however, this approach doesn't actually work very well on the mac because this platform uses the GoogleAppEngineLauncher, so none of the app engine code is installed in the python path. Again, I could get around this, but it's a bunch of work and my collaborators would have to do different work arounds for their platforms.

Finally I came to GAEUnit, which was almost what I wanted. From a testing perspective, this solution is great, but if you look at the setup instructions, the authors suggest that you drop their gaeunit.py in your appengine directory, and create a /test* url in your configuration.

I don't like this for a couple of reasons. First I want to keep my test code seperate from my deployed application code. There is no reason to have to deploy my test code in my production application. The extra code can lead to confusion, and possibly to bugs. Also, I was nervous about adding another URL target that I would have to support, even if I can ensure that the tests self-destruct when they are run in production.

I came up with a workaround, that I'm pretty happy with. I created a second appengine configuration in our repository to house the tests, so now my code tree looks like this:

severedelays/appengine/... (This is where my production code lives).
severedelays/appengine-test/...(This is where my test code lives).

So, this allows me to keep my test code out of my production code. All I need to do to import my production code is to create a couple of relative soft links between the two directories for my lib and third_party directories.

Now, when I'm working on the code I can startup a dev sever for both appengine configurations. In the first I can test what the app looks like, and in the second I can run the tests.

This also has the advantage of seperating the datastore for the test instance from my development instance. Overall, I'm pretty happy with this setup.

Sunday, January 4, 2009

Severe Delays - London Underground Tube Status API

I spent most of my holiday break relaxing and catching up on little projects around the house. I did manage to get some time together to build a service that I have wanted for awhile.

As many of you know, I wrote a little iGoogle gadget to display the current status of the London Underground network (the Tube). It worked well, but relied on a backend that I didn't have any administrative control over. So, when the TFL changed their page layout, which they seem to do a couple of times a year, it took awhile to get things fixed.

The last time this happened, I dropped an email to Malcolm Barclay (author of the great iPhone TubeStatus app) and asked him if he would like to collaborate on this problem. He agreed, and we were off.

I put together a source code repository and a site at www.severedelays.org. The API is still a little new, but I've been running my iGoogle gadget on it for about a week now with no serious trouble. It's pretty easy to use and I provide data in two formats XML and JSON.

To make a request you fetch the following url:



This will give you an XML formatted doc with all of our most recent information (right now that is just tube lines, but more is coming). If you prefer JSON then change the format to json.

The next release, which will probably come out in a week or so, will include information for tube, dlr, and London Overground, as well as the messages for each station. There will be an API for getting at particular pieces of data (/uk-lon/lines/current or /uk-lon/stations/current).

You might ask why I've got the uk-lon identifier in the URL. That is where you come in. Do you want to include data from your own network? I would love to hear from you. It would be great to get information from any and all mass transit networks, and even road congestion data too.

This service runs on top of Google's App Engine. I hope you find this useful, and please drop me a line if you have any questions.

More Protests

from Kensington, Greater London, UK
Last night and tonight have brought  more protests in London. Last night there was a large demonstration at Trafalger Square, and the an attempted march toward Kensington, but apparently the police blocked that from taking place. The protesters reassembled at High Street Kensington for a couple of hours in front of the Israeli embassy.

Jenna and I saw the protests on our way to get groceries last night. There were a lot of angry people in the road, and the police had traffic on Kensington High Street blocked off. As we were watching the protests, people started throwing things towards the police, or maybe towards the embassy (the police were standing between the crowd and the embassy so it's hard to say).

A line of about 100 police in full riot gear moved in, and that was when Jenna and I decided to move. We didn't want to be between the police line and the crowd. Over the next hour or so the police segmented and dispursed the crowd.

There was a new demonstration tonight, but it didn't have the same force of the group last night, and organizers are promising another large demonstration next weekend.