|
|
@ -1,7 +1,7 @@
|
|
|
|
#!/usr/bin/python
|
|
|
|
#!/usr/bin/python
|
|
|
|
|
|
|
|
|
|
|
|
import os, argparse, hashlib, email, glob, sqlite3
|
|
|
|
import os, argparse, hashlib, email, glob, sqlite3
|
|
|
|
|
|
|
|
print sqlite3.version
|
|
|
|
parser = argparse.ArgumentParser(description='Parses emails into an SQLite database, and optionally renders static HTML files.')
|
|
|
|
parser = argparse.ArgumentParser(description='Parses emails into an SQLite database, and optionally renders static HTML files.')
|
|
|
|
|
|
|
|
|
|
|
|
parser.add_argument('-p', '--pattern', dest='pattern', action='store', default='*',
|
|
|
|
parser.add_argument('-p', '--pattern', dest='pattern', action='store', default='*',
|
|
|
@ -13,6 +13,15 @@ parser.add_argument('-r', '--render', dest='render', action='store_true',
|
|
|
|
args = parser.parse_args()
|
|
|
|
args = parser.parse_args()
|
|
|
|
options = vars(args)
|
|
|
|
options = vars(args)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
database = sqlite3.connect('emails.db').cursor()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
# Try to create the table
|
|
|
|
|
|
|
|
database.execute("CREATE TABLE emails (`message_id`, `from`, `to`, `subject`, `date`, `body`, `html`)")
|
|
|
|
|
|
|
|
except sqlite3.OperationalError:
|
|
|
|
|
|
|
|
# Table already exists
|
|
|
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
file_list = glob.glob(options['pattern'])
|
|
|
|
file_list = glob.glob(options['pattern'])
|
|
|
|
|
|
|
|
|
|
|
|
for email_file in file_list:
|
|
|
|
for email_file in file_list:
|
|
|
@ -28,3 +37,4 @@ for email_file in file_list:
|
|
|
|
|
|
|
|
|
|
|
|
sha1_hash = hashlib.sha1("%s/%s/%s/%s" % (message['from'], message['to'], message['message-id'], subject)).hexdigest()
|
|
|
|
sha1_hash = hashlib.sha1("%s/%s/%s/%s" % (message['from'], message['to'], message['message-id'], subject)).hexdigest()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|