From af54119a8d1ea2a653249aa3ba9f4a712af9cede Mon Sep 17 00:00:00 2001 From: Tom Ritter Date: Tue, 26 Jan 2016 00:23:21 -0500 Subject: Fixing PeerChecker to actually work, and report details of a failure --- jobs/PeerChecker.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'jobs/PeerChecker.py') diff --git a/jobs/PeerChecker.py b/jobs/PeerChecker.py index c8cca38..965f4a4 100755 --- a/jobs/PeerChecker.py +++ b/jobs/PeerChecker.py @@ -5,6 +5,7 @@ import base64 import datetime import imaplib +import requests import JobBase @@ -18,22 +19,28 @@ class PeerChecker(JobBase.JobBase): peer = p[1].split(',') peerOK = False + subject = "" + body = "" + try: response = requests.get(peer[0]) if response.status_code != 200: peerOK = False subject = peer[0] + " returned a non-standard status code." + body = str(response.status_code) + "\n" + response.content else: if "True" in response.content: peerOK = True elif "False" in response.content: peerOK = False subject = peer[0] + " reports it cannot send email." - except: + body = str(response.status_code) + "\n" + response.content + except Exception as e: peerOK = False subject = peer[0] + " is not responding." + body = str(e) if not peerOK: - if not self.sendEmail(subject, "", peer[1]): + if not self.sendEmail(subject, body, peer[1]): testSuccess = False - return testSuccess \ No newline at end of file + return testSuccess -- cgit v1.2.3