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/PeerChecker.py | |
parent | 65e71a10d23a70cd9dfdd6922b87802ad72f4eac (diff) |
Fixing PeerChecker to actually work, and report details of a failure
Diffstat (limited to 'jobs/PeerChecker.py')
-rwxr-xr-x | jobs/PeerChecker.py | 13 |
1 files changed, 10 insertions, 3 deletions
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
|