diff options
author | Tom Ritter <tom@ritter.vg> | 2016-01-26 00:23:21 -0500 |
---|---|---|
committer | Tom Ritter <tom@ritter.vg> | 2016-01-26 00:23:21 -0500 |
commit | af54119a8d1ea2a653249aa3ba9f4a712af9cede (patch) | |
tree | c79376ab9919f7665962108d714c2a2c79196451 /jobs | |
parent | 65e71a10d23a70cd9dfdd6922b87802ad72f4eac (diff) |
Fixing PeerChecker to actually work, and report details of a failure
Diffstat (limited to 'jobs')
-rwxr-xr-x | jobs/EmailChecker.py | 4 | ||||
-rwxr-xr-x | jobs/PeerChecker.py | 13 |
2 files changed, 12 insertions, 5 deletions
diff --git a/jobs/EmailChecker.py b/jobs/EmailChecker.py index 51992bf..f65ed17 100755 --- a/jobs/EmailChecker.py +++ b/jobs/EmailChecker.py @@ -40,7 +40,7 @@ class EmailChecker(JobBase.JobBase): M.logout() if not foundSubject: #This may not work, but try anyway - self.sendEmail("Email Fetch Failure", "Body") + self.sendEmail("Email Fetch Failure", "") return False else: - return True
\ No newline at end of file + return True 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
|