After losing interest in Google’s not so spectacular tasks addon, and not wanting to use or pay for other people’s web based Todo lists I found MyTinyTodo which seems to work quite nicely. It also has the added bonus of being something I can install on my own personal webserver. The only thing it lacked was some sort of email reminder system so I decided to see if I could write one.
To make it work you will need to install the following piece of SQL into your database which creates a small stored procedure to retrieve the data:
DELIMITER $$ DROP PROCEDURE IF EXISTS ListTodos$$ CREATE PROCEDURE ListTodos() BEGIN SELECT mtt_lists.name,mtt_todolist.title,IFNULL(duedate,"No Date") AS duedate,mtt_todolist.prio FROM mtt_lists LEFT JOIN mtt_todolist ON mtt_lists.id=mtt_todolist.list_id WHERE mtt_todolist.prio IS NOT NULL ORDER BY mtt_todolist.duedate DESC,mtt_todolist.prio DESC; END$$ DELIMITER ;
mysql -u todo -p < todo.sql
After that, the following tiny Python script can be called by cron to periodically email the todo list
#!/usr/bin/python # -*- coding: utf-8 -*- import MySQLdb as mdb import sys import smtplib from email.mime.text import MIMEText try: conn = mdb.connect('localhost', 'todo', 'todo', 'todo'); cursor = conn.cursor() cursor.execute("CALL ListTodos();") rows = cursor.fetchall() text = "Here is the daily TODO reminder from http://home.piku.org.uk/mytinytodo" for row in rows: text = text + "\nList %s: Priority %d, Due : %s - %s" % (row[0],row[3],row[2],row[1]) msg = MIMEText(text) msg['Subject'] = 'Daily TODO Reminder' msg['From'] = 'your-email@here.com' msg['To'] = 'your-email@here.com' cursor.close() conn.close() s = smtplib.SMTP('localhost') s.sendmail ('your-email@here.com','your-email@here.com',msg.as_string()) s.quit() except mdb.Error, e: print "Error %d: %s" % (e.args[0],e.args[1]) sys.exit(1)
My crontab contains this line to run the script at 7am each day.
0 7 * * * james /home/james/scripts/todo_email.py
At the moment the output is fairly rudimentary with no formatting or layout. I might modify the output later after some more testing.


Pingback: myTinyTodo Development Blog » 3d-party myTinyTodo improvements