Tag Archives: Python

Tasky: A CLI Google Tasks Client in Python

I’ve been looking for a nice and fast Google Tasks client for a long time. There do exist a lot of them but none that I have encountered matched what I was looking for in terms of functionality and ease of use. Given that I have a bit of free time this summer, I decided to write one myself.

This task would have been really hard and clunky a month ago. Luckily, Google introduced the Tasks API about three weeks ago, a hugely requested feature. I hadn’t worked with Google APIs before so I took it up as a challenge to figure out how it all works and put together my client in a few days’ time. I also decided to go with Python this time, as I’d like to get more practice with the language (which I this is really amazing, by the way). The result of the past three days is a very simple and fast client for Google Tasks that works in the command line.


First, I had to define what I wanted to accomplish with this project. I wanted a way to retrieve tasks from one or more task lists (I currently have one but have used multiple in the past), have a way to quickly add, remove, and check/uncheck tasks. I wanted the whole thing to work in the terminal, as that’s where I spend most of my time working. And I wanted the commands to be as short as possible, as to minimize the amount of typing necessary. Specifically, I did not want to have to type an entire task’s name in order to perform some action on it. And I wanted the whole thing to take as little time as possible between subsequent operations – I didn’t mind a possibly shutdown if I could have fast removes and adds and toggles while the application was open. Finally, I wanted to have two modes: Normal Mode and Quick Mode. In Normal Mode, the application is opened and kept running, allowing me to make a series of changes to it before closing. In Quick Mode, I perform a single operation fully specified as arguments in the command line. The changes are made (with ambiguities resolved when necessary) and the application closed immediately. And I wanted to have it do authentication in order to access account information from any computer I choose to run the application on.


I was able to accomplish all of these goals by loading all task lists into memory upon startup and committing all changes to the server when closing the application. The Tasks API is still in Labs, which means it could change from the time of this writing, but as of right now, retrieving everything requires N+1 API calls, where N is the number of task lists in a given account. So that was fairly quick. I used Google’s sample code almost verbatim for OAuth 2.0 authentication (yay security!) and that’s usually the slowest part of the application. It does cache credentials, but still takes a bit of time to establish a secure connection. Once all the data is retrieved, I decided to store it in memory as a dict of dict of lists of task objects – which are just dicts themselves. That’s a lot of dictionaries, but it made sense since I was able to get to fast accesses, insertions, and deletions. As part of the way I implemented the code, the dictionary of tasks had to be an OrderedDict; if you look at the code, it’ll make sense why. I then performed changes on the in-memory task lists as the user made changes, but those changes were only reflected via flag statuses and not actually performed. Then, when the application is closed, I sent back just the changes, minimizing the number of total API calls.


The result is a little application that I’m fairly proud of. It does what I need it to do and I actually do use it. There’s currently no documentation beyond what’s in the source code and the code is still a bit rough around the edges. The link to my repository is here. As mentioned on that page, this application requires Python >=2.7, Google API client for Python, and the Fabulous library (used for having bold and strike-through text in the terminal). I have not included the Client ID, Client Secret, or Developer Key values in this code, but you can get those values by registering this application for yourself via the Google API Console. The code itself is fully open-source and you are free to use or modify it as you wish. It’s still in development, so look out for changes in the future.


Posted by on May 31, 2011 in Uncategorized


Tags: , , , , ,

Quick Update on Summer

I’ll write more later on but I just wanted to give a quick update on how my summer has been going. So I’ve started my research at Princeton about three and a half weeks ago and so far it’s going pretty well. Mostly it’s a lot of data analysis work and a fair bit of programming. That’s a very good thing. Honestly the more I think about it the more I realize that programming is what I love more than anything else. I’m effectively thinking about programming all the time anyway, always trying to look at the world through the lens of computer science (of what little I know of it) and so to have the opportunity to actually do it for the summer is quite cool. I’m working on servers running a variety of 64-bit Linux flavors, most of which have at least four cores and 8 gigs of RAM. The computational capacity of them is really amazing and the ability to run in parallel at acceptable speeds makes life easier. I’m extremely happy with the tools I’m using – straight manual Makefiles, gcc, gdb, and emacs/vim. As far as code is concerned, it’s mostly C, some Java, and very often Bash scripts with occasional AWK or Perl for quick things. For some reason I’ve found this setup more easy to work with than an actual high-powered IDE. Weird, perhaps, but I sure hope wherever I work in the future I will be afforded this same luxury.

The more I work with Linux, the more advantages I see. I was comfortable with Bash coming in this summer and I’ve learned even more after working exclusively with it. Linux feels like it was designed solely for the purpose of making a programmer’s easier and its done a great job at that. I’ve learned a lot more of Bash scripting now and I’m always amazed at how powerful it is. It’s an extremely useful language to know. For source control, I pretty much had the choice of deciding what I wanted to use and I chose SVN although I think I should’ve perhaps gone with Git. It’s been many months since I’ve used SVN but it was very easy to catch on again. It also forces me to be organized with my code and be more standardized so I’m not going to complain :).

For collaboration, I suggested we use Google Wave to keep a running to-do list and so far it’s working beautifully. It really is the best way to keep track of ideas (although I still maintain an ongoing to-do list on the whiteboard and on my Google Tasks because I’m weird like that). Checking off completed items is pretty damn thrilling – I love the feeling of making progress.

Apart from working on my current research, I’m also doing some light QA/Testing for Mozilla. I’m on the nightly builds (Minefield) on my Linux and Windows 7 partitions (though I use (Linux almost always). But I think that’s helpful here because there are far fewer Linux testers anyway. Mostly it’s just running Litmus tests, benchmarks, and giving feedback on UI/UX changes as they appear and/or break :). It’s a cool feeling to get daily updates and check out what new patches were made and to see the design process through the eyes of the developers. I’m also running on the dev branch of Google Chrome and there too it is interesting to witness the evolution of the interface and behavior. One day I imagine myself actually a developer at one of these companies, pushing out updates to millions of users… that’s something I like to think about everyday. I know it’s silly but I get a kick out of pretending that every commit I make has some tremendous influence. Maybe one day it will be so and all this is good preparation for that I guess :).

This summer my main goals are to of course continue my research but also to learn Python and master C++ properly. I have a somewhat adequate knowledge of C++ right now but I never learned it formally – I want to take this summer to actually learning the finer details of the language. Being that many, many applications are written in that language and that it’s widely the most popular language for programming contests too, it is certainly worth learning. As far as Python, I know that I won’t regret learning that. Seeing how much I’ve come to respect the power of quick and dirty Bash scripts, I know I’ll love the even greater power, flexibility, and ease of use of Python. A few of my friends are learning it too this summer, some for whom it is their first language and this further motivates me to learn it.

I’m going to be taking next week off from research for precisely these reasons among others. Princeton has really tired me out a great deal and I need some time to rest and regroup. I hope to take it a lot easier and to get started on learning those languages. I’ve also got to continue work on the Princeton Math Club blog. For that, I’m thinking of implementing the new Post Type feature that WordPress 3.0 brings. And for that, I need to polish up some PHP skills and get to work hacking away at the current theme. Looks rather straightforward so it shouldn’t take too long to do.

Okay so this post is freaking long and not quick at all. It also took quite a while to type out since I wrote it from the WordPress app on my Droid. More on that in an upcoming post. But for now, that’s about it.

1 Comment

Posted by on July 7, 2010 in Uncategorized


Tags: , , , , , , , , ,