You are not logged in.
Pages: 1
## check-gmail.py -- A command line util to check GMail -*- Python -*-
## modified to display mailbox summary for conky
# ======================================================================
# Copyright (C) 2006 Baishampayan Ghose <b.ghose@ubuntu.com>
# Modified 2008 Hunter Loftis <hbloftis@uncc.edu>
# Time-stamp: Mon Jul 31, 2006 20:45+0530
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
# ======================================================================
import sys
import urllib # For BasicHTTPAuthentication
import feedparser # For parsing the feed
from textwrap import wrap
_URL = "https://mail.google.com/gmail/feed/atom"
uname = sys.argv[1]
password = sys.argv[2]
maxlen = sys.argv[3]
urllib.FancyURLopener.prompt_user_passwd = lambda self, host, realm: (uname, password)
def auth():
'''The method to do HTTPBasicAuthentication'''
opener = urllib.FancyURLopener()
f = opener.open(_URL)
feed = f.read()
return feed
def readmail(feed, maxlen):
'''Parse the Atom feed and print a summary'''
atom = feedparser.parse(feed)
print '${color}Mail: %s@gmail.com (%s new)\n' % (uname, len(atom.entries))
for i in range(min(len(atom.entries), maxlen)):
print ' ${color}"%s"' % atom.entries[i].title
print ' ${color lightgrey}%s' % atom.entries[i].author
if len(atom.entries) > maxlen:
print ' ${color}more...'
if __name__ == "__main__":
f = auth() # Do auth and then get the feed
readmail(f, int(maxlen)) # Let the feed be chewed by feedparser
Last edited by earle79 (2008-12-21 05:53:31)
Offline
${font FreeSans:bold:size=12}${color 99CCFF}EMAIL${color}${font}
${hr}
GMAIL:$alignr${execpi 100 python ~conkyscripts/gmail/gmail_parser.py earlesimers@gmail.com password passwordhere}
Offline
I've created a modified version just to show the count of new mails.
Exec using
check-gmail.py <username> <password>
#!/usr/bin/python
## check-gmail.py -- A command line util to check GMail -*- Python -*-
## modified to display mailbox summary for conky
## modified to produce a count of new mail by Andrew Williams
# ======================================================================
# Copyright (C) 2006 Baishampayan Ghose <b.ghose@ubuntu.com>
# Modified 2008 Hunter Loftis <hbloftis@uncc.edu>
# Time-stamp: Mon Jul 31, 2006 20:45+0530
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
# ======================================================================
import sys
import urllib # For BasicHTTPAuthentication
import feedparser # For parsing the feed
from textwrap import wrap
_URL = "https://mail.google.com/gmail/feed/atom"
uname = sys.argv[1]
password = sys.argv[2]
urllib.FancyURLopener.prompt_user_passwd = lambda self, host, realm: (uname, password)
def auth():
'''The method to do HTTPBasicAuthentication'''
opener = urllib.FancyURLopener()
f = opener.open(_URL)
feed = f.read()
return feed
def readmail(feed):
'''Parse the Atom feed and print a summary'''
atom = feedparser.parse(feed)
print '%s new\n' % len(atom.entries)
if __name__ == "__main__":
f = auth() # Do auth and then get the feed
readmail(f) # Let the feed be chewed by feedparser
Offline
~conkyscripts/gmail/gmail_parser.py
Last edited by earle79 (2008-12-21 20:21:41)
Offline
Pages: 1
Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.
Server: acrobat