Skip to content

Instantly share code, notes, and snippets.

@yanyaoer
Created May 19, 2013 20:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yanyaoer/5608923 to your computer and use it in GitHub Desktop.
Save yanyaoer/5608923 to your computer and use it in GitHub Desktop.
send gmail unread message with notification center
''' git clone
https://github.com/maranas/pyNotificationCenter.git
https://github.com/thedjpetersen/gmaillib.git
(!!!) gmaillib.py line 51 has indents error, add ' ' before 'if'
https://github.com/thedjpetersen/gmaillib/blob/master/gmaillib.py#L51
'''
import tornado.ioloop
from gmaillib import gmaillib
from pyNotificationCenter import pyNotificationCenter as nc
timer = 1000 * 60 * 30 # 30 min
account = gmaillib.account('GMAIL_ACCOUNT', 'GMAIL_PASSWORD')
def schedule():
unread = account.unread()
if unread:
for mail in unread:
nc.notify(mail.subject,
"from: %s" % mail.sender_addr,
"date: %s" % mail.date,
sound=True)
tornado.ioloop.PeriodicCallback(schedule, timer).start()
tornado.ioloop.IOLoop.instance().start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment