Making textmate virtualenv aware

So I am using textmate for my python development, but I wanted it to pick up any virtualenv configured in a project. Here’s how to hack the python bundle…

First off, the run script command needs to be aware of the virtualenv stuff. So open up the bundle editor, and replace this:

is_test_script = ENV["TM_FILEPATH"] =~ /(?:\b|_)(?:test)(?:\b|_)/ or
File.read(ENV["TM_FILEPATH"]) =~ /\bimport\b.+(?:unittest)/

TextMate::Executor.run(ENV["TM_PYTHON"] || "python", "-u", ENV["TM_FILEPATH"]) do |str, type|

with:

is_test_script = ENV["TM_FILEPATH"] =~ /(?:\b|_)(?:test)(?:\b|_)/ or
File.read(ENV["TM_FILEPATH"]) =~ /\bimport\b.+(?:unittest)/

# default python
python = ENV["TM_PYTHON"] || "python"

# try for virtualenv if it exists
if ENV.has_key?("TM_PROJECT_DIRECTORY")
virtualenv_python = ENV["TM_PROJECT_DIRECTORY"] + "/bin/python"
if FileTest.exists?(virtualenv_python)
python = virtualenv_python
end
end

TextMate::Executor.run(python, "-u", ENV["TM_FILEPATH"]) do |str, type|

Now, we also want the unit tests to pick up that environment as well, so you need to do the same with the Run Project Unit Tests command. I am using nose to collect tests, and the nosexml plugin to format the results. You should install them if you need to. Replace:

# Find all files that end with "Test.py" and run
# them.

find . -name "*Test.py" -exec "${TM_PYTHON:-python}" '{}' \;|pre

with:

cd $TM_PROJECT_DIRECTORY
if [ -f bin/activate ]
then
source bin/activate
fi
nosetests --xml --xml-formatter=nosexml.TextMateFormatter

PS, it seems like the python bundle needs some love, anyone know the maintainer?

An interesting new campaign

RentalRights looks like it is finally getting a campaign together to organise in support of people who rent. If you rent and live in the uk you should check it out. No other country seems to treat tenants so badly.

chimpy: MailChimp API for python

I needed to use MailChimp from a Django app, so I have knocked up a wrapper for their API. Come on over to the google code site for chimpy if it is useful to you.

Why you shouldn’t use BT business

My new office use BT for their ADSL. We had a problem with mail disappearing between people in the office. So I emailed BT and asked them what was happening. Before they would help, they needed three emails in the last 72 hours that had disappeared.

I provided three emails satisfying this criteria. I did what most people would do and sent an email with the subject ‘test’ which was not delivered and sent this to BT. Their response was that emails with the word test in the subject line would be spam filtered, and you cannot access to the mails they have filtered. Since we are a company that performs tests, I asked if this could be removed? BT said that they could not do this. OK, so can BT just whitelist all mails within our domain? Again, no.

BT also cannot provide email lists. Think about that. The flagship British technology company is incapable of providing your business with an email list. That is so poor, I’m speechless.

All in all, BT don’t seem capable of providing reliable email service and are also not willing to help fix problems when they occur. And their online management interface sucks as well. Avoid.

When you add in phorm to this, I see no reason to ever use a BT product if you can avoid it.

Snooper’s Paradise

Sign from Snooper's paradise, Brighton This week’s column is about the Home Office’s alleged new plans to keep a centralised record of the nation’s communications traffic data:

Can you “persuade others of the benefits of proposals or the value of a particular interpretation”? Then perhaps the recently advertised position of senior information officer at the Home Office’s new Intercept Modernisation Programme (IMP) is for you.

According to the description of the £45,000-a-year job (removed from the Home Office website, but, at the time of going to press, still available in Google’s cache), the IMP has been set up to “maintain the UK’s capability to obtain and exploit Lawful Intercept (LI) product and Communications Data (CD)”, using “a range of new technologies”. You and I will know IMP better as the nutty plans that have been making headlines all summer, plans to log details about every web page we visit, every SMS message we text and every email we send. And not only that, but to store all this “communications traffic” information in a central database.

Read the rest here.

Last night, I enjoyed watching Mischief: Your Identity for Sale on BBC3. This style of documentary (very Michael Moore) always leaves me wondering how much the film-makers massaged the facts to sensationalise the story. But being somewhat of an expert in these matters, thanks to my work with ORG, I know they’ve got it right on the money here. Michael Wills MP (who is in charge of Data Protection) and David Smith, Deputy Information Commissioner, come off particularly badly. Find out more about the programme here, and watch it for the next 7 days here.

(Snooper’s Paradise is an excellent permanent flea market in the North Laine in Brighton. I love it. The picture above is taken from their store front.)

2600: The Hacker Quarterly

This week’s Reboot column is on The Best of 2600: a Hacker Odyssey:

“That evening he unpacked his books from London. The box was full of things he had been waiting for impatiently: a new volume of Herbert Spencer, another collection of the prolific Alphonse Daudet’s brilliant tales, and a novel called Middlemarch, as to which there had lately been interesting things said in the reviews. He had declined three dinner invitations in favour of this feast . . .”

There’s something about receiving a parcel from Amazon that takes me back to 19th-century New York. Breaking the seal on a bulk order of books (I’m a sucker for super-saver delivery) makes me feel like Newland Archer in The Age of Innocence, ready to retire from society to my oak-panelled study with only a smoking jacket and a box of cigars for company. So it was last week, when I unpacked The Best of 2600: a Hacker Odyssey (John Wiley & Sons, £21.99).

You can read the rest here. James has kindly made an RSS feed for Reboot (the NS don’t provide one) for those who want to stay up to date.

TextMate with nose

If you want to use nose as your test runner while developing with TextMate, then you need the nosexml plugin. Install and then follow these instructions.

Watching from beneath

This week’s New Statesman column is on sousveillance:

Watching Amy Winehouse lash out at Glastonbury this year (YouTube brings out the worst in me), I was surprised by the number of cameraphones the star had thrust in her face by the front row of the Pyramid Stage crowd. When your fans start treating you as badly as the paparazzi do, is it any wonder you crack?

This column has written a lot about surveillance, but in a world of cheap, portable technology, there is also sousveillance.

Sousveillance, or “watching from underneath”, counters the unblinking eye in the sky with millions of tiny blinking ones belonging to each one of us. In the surveillance society, or so the theory goes, sousveillance is the tool of the surveilled, keeping a watchful eye on the watchers.

Read the rest here.

Milky, milky

Holiday Snap, CroatiaDigging this new theme (Thanks, James!). Because my New Statesman column doesn’t have a dedicated RSS feed, I’m going to do my best to post links to my columns here, so those who wish to can keep updated.

Here’s this week’s column, on touching up your holiday snaps (see one such touched up snap, right):

My youth is captured for posterity by a series of blurred close-ups depicting me and my best friend in various locations in northern France, squinting into the sun as we attempt to point a Boots disposable camera at ourselves in the style of Thelma and Louise.

Inevitably, half of one of our faces is always out of shot. But things have come a long way since then. With digital photography, long gone are the days of walking into people as you left the chemist’s, flicking through the 30 overexposed, or pitch-black, photos in order to locate the six half-decent album candidates.

Read the rest here.

I’m posting this from Brighton today, where I’m enjoying a four day break, most of which I’ll be spending here.

New theme

White as milk, which looks great.

Also trying out ecto as a client.