summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcoderick142017-06-30 01:45:37 +0530
committercoderick142017-06-30 01:45:37 +0530
commit32b25daa11719ee5a7dc4b51517ffec03e44e45d (patch)
treed3ed22e60a45951079cb4e9a5334e44e892516b6
parent000f50a2ae71d6e938ab7841fdf8ccbc2fedd3c2 (diff)
downloadSBHS-2018-Rpi-32b25daa11719ee5a7dc4b51517ffec03e44e45d.tar.gz
SBHS-2018-Rpi-32b25daa11719ee5a7dc4b51517ffec03e44e45d.tar.bz2
SBHS-2018-Rpi-32b25daa11719ee5a7dc4b51517ffec03e44e45d.zip
Dump mail when unable to send
-rw-r--r--sbhs_server/tables/management/commands/send_report.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/sbhs_server/tables/management/commands/send_report.py b/sbhs_server/tables/management/commands/send_report.py
index 00b279b..99b8359 100644
--- a/sbhs_server/tables/management/commands/send_report.py
+++ b/sbhs_server/tables/management/commands/send_report.py
@@ -2,6 +2,7 @@ from django.core.management.base import BaseCommand, CommandError
from sbhs_server import settings, helpers
from sbhs_server.tables.models import Board
import os, json
+from datetime import datetime
class Command(BaseCommand):
args = ''
@@ -53,7 +54,7 @@ class Command(BaseCommand):
message += "MID : {} Cause : {}\n" .format(key,faulty_boards[key])
message += "\nYou can check the SBHS status on http://vlabs.iitb.ac.in/sbhs/admin/."
message += " Possible correction actions are:\n"
- message += "1. Run this command without brackets -> ( cd $SBHS_SERVER_ROOT; ./cron_job.sh )\n"
+ message += "1. Run this command without brackets -> ( cd $SBHS_SERVER_ROOT; ./new_cron_job.sh )\n"
message += "2. If same machine comes offline multiple times, replacement of the machine is advised.\n\n\n"
message += "Regards,\nSBHS Vlabs Server Code"
@@ -61,6 +62,13 @@ class Command(BaseCommand):
subject = "SBHS Vlabs: Notice - SBHS not connected"
# Send email
- if len(new_offlines) > 0 or len(faulty_boards)>0:
- for admin in settings.SBHS_ADMINS:
- helpers.mailer.email(admin[2], subject, message)
+ try:
+ if len(new_offlines) > 0 or len(faulty_boards)>0:
+ for admin in settings.SBHS_ADMINS:
+ helpers.mailer.email(admin[2], subject, message)
+ except Exception as e:
+ with open("mail_dump.txt", "a") as handler:
+ delimiter = " " + "#"*10 + " "
+ handler.write("\n" + delimiter + datetime.now().strftime("%Y-%m-%d %H:%M:%S") + delimiter + "\n")
+ handler.write(message)
+ print message