Friday, 12 April 2013

Heroku Scheduler and the UnicodeEncodeError

Ruminate runs a scheduled task on Heroku every hour to grab the new entries from the configured news feeds.

I was noticing that some feeds were not updating, checking the logs I saw that I was getting a:
'ascii' codec can't encode character u'\u2022' in position 49: ordinal not in range(128)
This was odd because if I ran it from the command line on my machine it worked, and even stranger when I ran it with the heroku run it also worked.

Turning to Google I found this answer on StackOverflow -

The long and short of it is that the print statement will happily default to ascii in python, if not told otherwise.  I am guessing that when run from my console it picks up that it is utf8, but when running detached it defaults back to ascii.  As the answer states this is an easy fix by just setting enviroment variable PYTHONIOENCODING to the codec that you want.  In this case utf8.

Running the following command sets the environment variable on the heroku app to the correct value:
heroku config:add PYTHONIOENCODING=utf8
This fixed the issue, and got my missing entries into the app. 

Hope this helps.

Tuesday, 2 April 2013

Announcing Ruminate

A week ago I challenged myself to write a simple Google reader clone. 

The reason being that I wanted to write a non-trivial piece of python code, and document the creation process.

It is now in version 0.1.  I have released it onto heroku and it works for my reading needs. 

You can see the Trello board at

and the code here

Currently Ruminate really only works for me, but in the coming weeks I hope to add more functionality (as seen on the trello board) if you want access find me at @vipox or follow the instructions on how to set it up on heroku yourself.

In the coming days I hope to blog the development of the app!