aboutsummaryrefslogtreecommitdiff
path: root/jobs/PeerChecker.py
diff options
context:
space:
mode:
authorTom Ritter <tom@ritter.vg>2020-09-08 13:36:01 -0400
committerTom Ritter <tom@ritter.vg>2020-09-08 13:36:01 -0400
commit4b3658ff1fc7a9877552bd006fc09b5e25f83854 (patch)
treedca42a113e0ec130ac5089dacdce5e3f157f478a /jobs/PeerChecker.py
parent9e24dfeaabd1c4daddb96c9c143f60cfa3374bf2 (diff)
Another python3 fix, and some error logging
Diffstat (limited to 'jobs/PeerChecker.py')
-rwxr-xr-xjobs/PeerChecker.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/jobs/PeerChecker.py b/jobs/PeerChecker.py
index 8db692c..52969b7 100755
--- a/jobs/PeerChecker.py
+++ b/jobs/PeerChecker.py
@@ -4,6 +4,7 @@ from __future__ import absolute_import
from builtins import str
import os
import base64
+import logging
import datetime
import imaplib
@@ -40,24 +41,26 @@ class PeerChecker(JobSpawner.JobSpawner):
self.subject = self.checkurl + " returned a non-standard status code."
self.body = str(response.status_code) + "\n" + response.content
else:
- if "True" in response.content:
+ content = response.content.decode("utf-8")
+ if "True" in content:
peerOK = True
- elif "MailProblem" in response.content:
+ elif "MailProblem" in content:
peerOK = False
self.subject = self.checkurl + " reports it cannot send email."
- self.body = str(response.status_code) + "\n" + response.content
- elif "JobProblem" in response.content:
+ self.body = str(response.status_code) + "\n" + content
+ elif "JobProblem" in content:
peerOK = False
self.subject = self.checkurl + " reports its jobs are not running."
- self.body = str(response.status_code) + "\n" + response.content
+ self.body = str(response.status_code) + "\n" + content
else:
peerOK = False
self.subject = self.checkurl + " had an unexpected response."
- self.body = str(response.status_code) + "\n" + response.content
+ self.body = str(response.status_code) + "\n" + content
except Exception as e:
peerOK = False
self.subject = self.checkurl + " is not responding."
- self.body = str(e)
+ self.body = repr(e) + "\n"
+ self.body += logging.traceback.format_exc()
return peerOK
def onFailure(self):