emailparser/render

27 lines
998 B
Plaintext
Raw Normal View History

2012-05-27 12:15:04 +02:00
#!/usr/bin/python
import os, argparse, hashlib, sqlite3, time
parser = argparse.ArgumentParser(description='Renders static HTML pages and indexes from an SQLite database of emails and an attachment folder.')
parser.add_argument('-d', dest='database', action='store', default='emails.db',
help='path of the database that should be used to render the e-mail files')
parser.add_argument('-a', dest='attachment_dir', action='store', default='attachments',
help='path where attachments are stored')
args = parser.parse_args()
options = vars(args)
2012-05-27 12:37:00 +02:00
if os.path.isfile(options['database']) == False:
print "Database file not found. Use the -d switch to specify a custom database path."
exit(1)
2012-05-27 12:15:04 +02:00
# Connect to database
database = sqlite3.connect(options['database'])
cursor = database.cursor()
2012-05-27 12:37:00 +02:00
for message in cursor.execute("SELECT * FROM emails"):
message_id, sender, recipient, subject, timestamp, textbody, htmlbody, sha1_hash = message