aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ritter <tom@ritter.vg>2016-01-26 00:35:30 -0500
committerTom Ritter <tom@ritter.vg>2016-01-26 00:35:30 -0500
commit109e568f7211d910155d7cd2334fa956d769e22a (patch)
tree8b0f8c8a3afbc0a6dfb535b6d53ddb169025c450
parentaf54119a8d1ea2a653249aa3ba9f4a712af9cede (diff)
Debugging why EmailChecker was failing. Added more details to the notification, and diagnosed it to a time window search issue.
-rwxr-xr-xjobs/EmailChecker.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/jobs/EmailChecker.py b/jobs/EmailChecker.py
index f65ed17..ee6db77 100755
--- a/jobs/EmailChecker.py
+++ b/jobs/EmailChecker.py
@@ -14,9 +14,12 @@ class EmailChecker(JobBase.JobBase):
def execute(self):
USER = self.config.get('email', 'user')
PASS = self.config.get('email', 'pass')
+
+ logdetails = ""
#Generate a random subject
subj = base64.b64encode(os.urandom(20))
+ logdetails += "Target subject is " + subj + "\n\n"
if not self.sendEmail(subj, "", USER):
return False
@@ -26,21 +29,26 @@ class EmailChecker(JobBase.JobBase):
#If we have set up a filter to auto-delete messages from ourself
if self.config.get('email', 'ideletesentmessagesautomatically'):
+ logdetails += "Switching to trash\n"
M.select("[Gmail]/Trash")
- criteria = '(FROM "'+USER+'" SINCE "'+datetime.date.today().strftime("%d-%b-%Y")+'")'
+ criteria = '(FROM "'+USER+'" SINCE "'+(datetime.date.today() - datetime.timedelta(hours=24)).strftime("%d-%b-%Y")+'")'
+ logdetails += "Criteria: " + criteria + "\n"
typ, data = M.search(None, criteria)
foundSubject = False
for num in data[0].split():
+ logdetails += "Found IMAP item" + str(num) + "\n"
typ, data = M.fetch(num, '(BODY.PEEK[HEADER.FIELDS (Subject)])')
+ logdetails += "IMAP details: " + str(data) + "\n"
if subj in data[0][1]:
+ logdetails += "Found the target subject!!\n"
foundSubject = True
M.close()
M.logout()
if not foundSubject:
#This may not work, but try anyway
- self.sendEmail("Email Fetch Failure", "")
+ self.sendEmail("Email Fetch Failure", logdetails)
return False
else:
return True