summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xtrain_bogofilter.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/train_bogofilter.py b/train_bogofilter.py
index 8bde56b..afd99c7 100755
--- a/train_bogofilter.py
+++ b/train_bogofilter.py
@@ -6,6 +6,7 @@ import logging
import os.path
import re
import subprocess
+import time
from ConfigParser import ConfigParser
# logging.basicConfig(format='%(levelname)s:%(funcName)s:%(message)s',
@@ -35,11 +36,15 @@ def process_folder(proc_fld_name, bogofilter_param, end_fld_name, mark_seen=True
msg = hparser.parsestr(msg_data[0][1])
date_str = msg['Date']
log.debug("date_str = %s", date_str)
- date_tuple=email.utils.parsedate_tz(date_str)
+ date_tuple = email.utils.parsedate_tz(date_str)
log.debug("date_tuple = %s", date_tuple)
# date_tulpe is 10-tuple (including time distance from GMT)
# but Time2Internaldate wants just 9-tuple
- int_date = imaplib.Time2Internaldate(date_tuple[:-1])
+ try:
+ int_date = imaplib.Time2Internaldate(date_tuple[:-1])
+ # For TypeError: 'NoneType' object is unsubscriptable
+ except TypeError:
+ int_date = imaplib.Time2Internaldate(time.gmtime(0))
log.debug("int_date = %s", int_date)
ret = subprocess.Popen(CMD_STR % bogofilter_param,