google tasks script rewritten and moved to github

I finally got around to rewriting my google tasks script (see previous posts here and here. The script has generated a fair amount of interest for this blog. After intending to do it for a while, I finally rewrote the program using the python module optparse, which is intended for parsing command line options and arguments. optparse is being deprecated in favor of argparse, which has been back ported from python 3.x to 2.7. But, given that I tend to use Apple’s python distribution, which is 2.6.1 in Leopard and SnowLeopard, I opted for optparse.

One of the nice elements of optparse is that it automates producing a help option for a command line program. In the spirit of the CLI, I rewrote the command options so that they are more bash-like. I’ve also changed it a bit to better handle posts w/o due dates, blank posts, and subtasks.

Also, because of the awkwardness of sharing scripts through, I moved the source to github. I also put the script up there to post to using with markdown that I wrote about here. That one needs some work, though. Particularly handling ascii/unicode issues and with uploading images.

At any rate, the v0.2 of myTasks works thusly (assuming you have the script on your path and/or with an alias):

Usage: tasks [option] arg1 arg2 arg3

--version show program's version number and exit
-h, --help show this help message and exit
-l Lists all tasks. Takes no arguments
Adds new task. Pass the name of the task list and the
new task as arguments in double quotes. For example:
tasks -n Main "Add this task to the Main list."
-c Clears completed tasks from your lists. Takes no
Updates a designated task as completed. Pass the name
of the list and the number of the task. The number is
available by first listing tasks with the -l command.
For example: tasks -u Main 1. This command would mark
the first message on the Main list as completed.
Deletes a designated task. Pass the name of the list
and the number of the task. The number is available by
first listing tasks with the -l command. For example:
tasks -d Main 1. This command would delete the first
message from the Main list.

It does just about all I want to do with it. I’m going to add the option to output all lists, or a designated list, but that’s about it for now. Please feel free to fork on github and make a pull request to improve it.

Update 9-20-2011: I pushed v0.3 of myTasks to github this morning. The new version uses a different commandline parser, and adds functionality with task listing options, the ability to rename or delete Lists, and a bit more.


Associate Professor of Early Latin America Department of History University of Tennessee-Knoxville

Tagged with: , , ,
Posted in programming
5 comments on “google tasks script rewritten and moved to github
  1. […] v0.2: I did finally move to github, and rewrote part of the script again too. See more here. Like this:LikeBe the first to like this […]

  2. Hey!

    I’m trying to use a script similar to this to get my google tasks onto ,my desktop using geektool. I have a weird problem. Whenever a swedish character (åäö) is included in the title of a task geektools fails miserably. It all looks fine in the terminal but somehow geektool won’t accept the åäö’s outputted through task[‘title’] even though they look exactly the same as if I’d do something like print(‘åäö’) and save it as and try that in geektool. What happens is that when the first row is encountered with a å, ä or ö in the title geektools just stops there and fails. The rows before are shown but that’s it!

    I did set the coding to uft8 in the beginning of the .py, I don’t have any ideas on what to do here, do you?

    You can reach me at kristian at plutonet stupid dot org – if a reply isn’t possible here!

    Remove STUPID (spam protection a la manual)

  3. ctb says:

    Hi Kristian–

    There’s an easy fix to this problem. GeekTool isn’t breaking, its python trying to coerce the output of your script to ASCII. You don’t see the stack trace error. Same thing happens if you use D-Term. So, what you need to do is to encode the string in task[‘title’].

    So, give this a try and see if it works:

    task['title'].encode('utf-8', 'ignore')

    Then, make sure that the geektool instance that displays your .txt file is set to utf-8.

    I rarely have such characters in my tasks, so I hadn’t dealt with it before, but I updated the script on github to handle unicode characters.

  4. Thank you so much, I had just no idea how to fix the problem as it all seemed to work great in the terminal. Now it works as expected in geektool, finally ;)

  5. […] and on making a static-site digital history archive. I did a series of posts (here, here, and here) on integrating Google Tasks on the command line. And, in that never-ending quest for an efficient […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


Hacer juicio ú dictamen acerca de alguna cosa... significando que el objeto excita el juicio ú dictamen en la persona que le hace.

Deducir ante el Juez la accion ú derecho que se tiene, ó las excepciones que excluyen la accion contrária.

RAE 1737 Academia autoridades
Buy my book!

Chad Black

I, your humble contributor, am Chad Black. You can also find me on the web here.
%d bloggers like this: