Tuesday, 27 October 2009

No module named _multiprocessing

I'm getting back into appengine at the moment, and I came across this error:

No module named _multiprocessing

A google search turned up this error report:


which lead to this post:


The problem was of-course, that I was using Python 2.6 instead of 2.5.

I love Linux, the solution is trivial:
The workaround for this is to install Python 2.5 on your machine. It will be then be accessible by using python2.5 on the command line. Then open thirdparty/google_appengine/dev_appserver.py in your favorite text editor and replace the first line,

#!/usr/bin/env python


#!/usr/bin/env python2.5

Note, I already had Python 2.5 installed via:

sudo apt-get install python2.5

Now, I'll promptly get back to figuring out how best to use DataStore to implement my solution!

Sunday, 11 October 2009

Amazon web services via Grails

I just recently noticed that Amazon have changed the way you invoke their Product Advertising API - you now need to sign requests as described in the Example REST Requests.

I obviously haven't been reading my emails, since the first clue came when I saw:

<Error><Code>MissingParameter</Code><Message>The request must contain the parameter Signature.</Message></Error>

Luckily, they have a java example demonstrating how to make an API request.

If you extract the source from this sample into your <GRAILS_APP>/src/java directory, then you can invoke the amazon api with code like:

[sourcecode language="java"]
import org.codehaus.groovy.grails.commons.ConfigurationHolder
import com.amazon.advertising.api.sample.*

class AmazonService {
private static final String ENDPOINT = "ecs.amazonaws.com";
private static final String AWS_SECRET_KEY = "put your secret key here";
private static final String AWS_ACCESS_KEY_ID = "put your access key here";

boolean transactional = false

* Call amazon lookup api.
* Returns xml document.
def getData(String asin) {
SignedRequestsHelper helper = SignedRequestsHelper.getInstance(ENDPOINT, AWS_ACCESS_KEY_ID, AWS_SECRET_KEY);

String requestUrl = null;
String title = null;

Map params = new HashMap();
params.put("Service", "AWSECommerceService");
params.put("Version", "2009-03-31");
params.put("Operation", "ItemLookup");
params.put("ItemId", asin);
params.put("ResponseGroup", "Small,Medium");

requestUrl = helper.sign(params);

def xml = new URL(requestUrl).text
return new XmlSlurper().parseText(xml)

You could, of-course, define your access keys in the Config.groovy class if you prefer.

(To find your identifiers, see http://docs.amazonwebservices.com/AWSECommerceService/latest/DG/index.html?ViewingCredentials.html)

Saturday, 10 October 2009

Locked subversion working copy

I don't know how it happened, but my local working copy got locked. This meant that every time I tried to commit, I got a 'working copy is locked' error.

The solution was easy, after I found a reference in the FAQ:
svn cleanup <directory>

Default open action for Ubuntu

Something happened on my Ubuntu install sometime which meant that double clicking on an HTML file resulted in the file being opened by gedit. Not really what I wanted. I started looking through the GNOME system menu (Preferences and Administration) to find how to change the default action - but that turned out to be the wrong place.

In Nautilus, simply right click on the file and select 'Properties'. From there, go to the 'Open with' tab and select the appropriate application.