tc icon indicating copy to clipboard operation
tc copied to clipboard

Error updating authors who don't have Klout scores

Open markpasc opened this issue 13 years ago • 0 comments

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 <module>
    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 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.

markpasc avatar Mar 09 '12 23:03 markpasc