hmason/tc — pull request #4 by markpasc (2012-03-09 23:25:56+00:00)
Title: Error updating authors who don't have Klout scores

Hi! I tried to use the `load_authors.py` script for the first time and got this error:

Traceback (most recent call last):
File "load_tweets.py", line 180, in
l = loadTweets(debug=True)
File "load_tweets.py", line 39, in __init__
self.fetchTweets(last_tweet_id)
File "load_tweets.py", line 111, in fetchTweets
self.update_authors(authors)
File "load_tweets.py", line 132, in update_authors
user['klout_score'] = response['users'][0]['kscore']
KeyError: 'users'

The `response` that caused the error is:

{
"status": 200,
"headers": [],
"body": {
"error": "No users"
}
}

This seems to occur for some Twitter users, I assume because they aren't in Klout's system at all and don't have Klout scores. I was able to get this response repeatably in [the interactive docs](http://developer.klout.com/io-docs) for my test Twitter account “mrakpsac”.

The attached patch cleared up the error for me by skipping these authors without trying to save a Klout score for them.