Blog

Yesterday was pretty eventful programming wise. I decided to resume working on the library-lookup module I created 5 months ago. The goal of the module is to query the Goodreads API for a list of books marked “to-read” by the user, then check to see if any of them are available in my local library’s ebook collection.

I had written the portion that connects to Goodreads and fetches the list of books back when I was working on it 5 months ago, but still have yet to get around to building the library portion because I’m fairly sure it will require some intensive web scraping. (Why don’t you have a public API yet, OverDrive?)

Yesterday, I decided to change the library-lookup methods to utilize classes. While I was doing this, I had the idea of adding the functionality to also check Amazon’s Kindle Lending Library. This meant having to figure out how to use Amazon’s API, which turned out to be incredibly confusing for new developers like myself. It involves signing up for two additional Amazon services, most notably Amazon Web Services. This was a bit daunting, because all I wanted was API access, yet they require you to sign up for a service that covers all aspects of their cloud computing platform. Fortunately, I found a wonderful Python wrapper which made the process of actually querying the AWS API moderately painless. Once that was done, I had to refresh my memory on how to use Python’s ElementTree to read the XML returned by Amazon. After struggling with that for an hour or two, I was finally able to get it working! Because I host the module on github, however, I needed to find a way to store my AWS credentials in a separate file so they wouldn’t be publicly available. I decided to use a config file, and after a few moments of googling I found the ConfigParser module which made this a piece of cake. I’d never messed with .cfg files before, but thanks to Python’s awesome documentation I had this up and going in a matter of minutes.

Speaking of GitHub, this is the point when I began to go a little crazy. I’m still fairly new to the way it works. I made the mistake of committing both my config file changes and my search_amazon changes in a single commit, when I really should have made them two separate commits. I spent the next two hours trying to figure out how to erase those commits so that I can resubmit them! For anyone out there who might have this problem in the future, (there is a severe lack of clear documentation on how to do this!) you can use the following command I found on stackoverflow:

git push -f origin HEAD^:master

Tip: You can increase the number of ^ symbols to rollback multiple commits.