Created
May 19, 2013 20:45
-
-
Save yanyaoer/5608923 to your computer and use it in GitHub Desktop.
send gmail unread message with notification center
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' 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