--- comics/status_scan.py 2018/02/06 14:59:10 1.1 +++ comics/status_scan.py 2018/02/12 13:30:58 1.2 @@ -1,6 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- +import datetime import json import smtplib import socket @@ -25,6 +26,9 @@ def generateMessageBody(report): for error in report['comics']: if error['error']: body += ' %-25s%s\n' % (error['comicName'], error['error']) + + if report.get('errorMessage'): + body += '\nAdditional Error Message:\n\t' + report['errorMessage'] return body @@ -37,7 +41,14 @@ def notifyErrors(report): def fetchStatusReport(source): response = urllib.urlopen(source) - return json.loads(response.read()) + results = json.loads(response.read()) + now = datetime.datetime.now() + shortDate = "%d%02d%02d" % (now.year, now.month, now.day) + if results['date'] != shortDate: + results['errorMessage'] = "Error: Comics not ran today!" + notifyErrors(results) + exit(2) + return results def main():