Skip parsing of message if headers cannot be decoded.

master
Sven Slootweg 13 years ago
parent a73ad71269
commit bda686499d

@ -175,7 +175,12 @@ for email_file in file_list:
timestamp = 0
print "WARNING: Failed to determine unix timestamp for %s." % sha1_hash
try:
new_row = (getheader(message['message-id']), getheader(message['from']), getheader(message['to']), getheader(subject), timestamp, textbody, htmlbody, sha1_hash)
except UnicodeDecodeError:
print "ERROR: Failed parsing %s, headers could not be decoded." % sha1_hash
continue
cursor.execute("INSERT INTO emails VALUES (?, ?, ?, ?, ?, ?, ?, ?)", new_row)
print "Successfully parsed and inserted e-mail with SHA1 hash %s." % sha1_hash

Loading…
Cancel
Save