Exemplo n.º 1
0
 def __init__(self, username, password):
     g = Gmail(username, password)
     
     graph_out = csv.writer(open('email_graph.csv', 'wb'))
     
     viewed_messages = []
     for folder in g.list_folders(): # iterate through all folders in the account
         # print "%s: %s" % (folder, g.get_message_ids(folder)) # NOTE: uncomment this to see which ids are in each folder
         for message_id in g.get_message_ids(folder): # iterate through message IDs
             if message_id not in viewed_messages: # ...but don't repeat messages
                 # print "Processing %s" % message_id
                 msg = g.get_message(message_id)
                 
                 for line in msg.split('\n'): # grab the from and to lines
                     line = line.strip()
                     if line[0:5] == "From:":
                         msg_from = line[5:].strip()
                     elif line[0:3] == "To:":
                         msg_to = line[3:].strip()
                     
                 try:
                     # print "%s, %s" % (msg_from, msg_to) # DEBUG
                     graph_out.writerow([msg_from, msg_to]) # output the from and to
                 except UnboundLocalError: # ignore if we can't read the headers
                     pass
Exemplo n.º 2
0
    def __init__(self, username, password):
        g = Gmail(username, password)

        graph_out = csv.writer(open('email_graph.csv', 'wb'))

        viewed_messages = []
        for folder in g.list_folders(
        ):  # iterate through all folders in the account
            # print "%s: %s" % (folder, g.get_message_ids(folder)) # NOTE: uncomment this to see which ids are in each folder
            for message_id in g.get_message_ids(
                    folder):  # iterate through message IDs
                if message_id not in viewed_messages:  # ...but don't repeat messages
                    # print "Processing %s" % message_id
                    msg = g.get_message(message_id)

                    for line in msg.split('\n'):  # grab the from and to lines
                        line = line.strip()
                        if line[0:5] == "From:":
                            msg_from = line[5:].strip()
                        elif line[0:3] == "To:":
                            msg_to = line[3:].strip()

                    try:
                        # print "%s, %s" % (msg_from, msg_to) # DEBUG
                        graph_out.writerow([msg_from,
                                            msg_to])  # output the from and to
                    except UnboundLocalError:  # ignore if we can't read the headers
                        pass
Exemplo n.º 3
0
#!/usr/bin/env python
# encoding: utf-8
"""
email_stats.py

Created by Hilary Mason on 2011-01-31.
Copyright (c) 2011 Hilary Mason. All rights reserved.
"""

import sys, os
from gmail import Gmail

if __name__ == '__main__':
    g = Gmail("*****@*****.**", "stratar0x")

    folder_stats = {}
    folder_stats['inbox'] = len(g.get_message_ids())

    for folder_name in g.list_folders():
        folder_stats[folder_name] = len(g.get_message_ids(folder_name))

    for folder_name, count in folder_stats.items():
        print "Folder %s, # messages: %s" % (folder_name, count)
Exemplo n.º 4
0
email_stats.py

Created by Hilary Mason on 2011-01-31.
Copyright (c) 2011 Hilary Mason. All rights reserved.
"""

import sys, os
from gmail import Gmail

if __name__ == '__main__':
	g = Gmail("*****@*****.**", "stratar0x")
	
	folder_stats = {}
	folder_stats['inbox'] = len(g.get_message_ids())
	
	for folder_name in g.list_folders():
	    folder_stats[folder_name] = len(g.get_message_ids(folder_name))
	    
	for folder_name, count in folder_stats.items():
	    print "Folder %s, # messages: %s" % (folder_name, count)


########NEW FILE########
__FILENAME__ = email_timestamps
#!/usr/bin/env python
# encoding: utf-8
"""
email_timestamps.py

Created by Hilary Mason on 2011-02-01.
Copyright (c) 2011 Hilary Mason. All rights reserved.