Skip to content

Commit

Permalink
#7 queue all notifications, add a cron script and configure in cron o…
Browse files Browse the repository at this point in the history
…n mws3 setup, added array of admin contacts in case sendingn fails
  • Loading branch information
S-Stephen committed Feb 16, 2017
1 parent da1a51e commit 3cca5ec
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
20 changes: 20 additions & 0 deletions deploy/mws3.cron
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import subprocess

def subprocess_cmd(command):
"""
Function used to run shell commands
This is Python that creates a Python env
which then runs Python commands - hhmmm
"""
process = subprocess.Popen(command,stdout=subprocess.PIPE, shell=True)
proc_stdout = process.communicate()[0].strip()
print proc_stdout


import os

filedir_path = "%s/.." % os.path.dirname(os.path.realpath(__file__))

schemacmd=". %s/env/bin/activate; %s/edpcmentoring/manage.py emit_notices --settings=edpcmentoring.settings_mws3 2>&1 | sed -e '/RemovedInDjango110Warning/d' | sed -e '/raven_return, name/d'" % (filedir_path,filedir_path)
subprocess_cmd(schemacmd)

5 changes: 5 additions & 0 deletions deploy/setup_mws3.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ def subprocess_cmd(command):
subprocess_cmd(copystatic)
print "done\n"

#install the cron job NB this wipes all other cron entries!:
print "installing the cronjob"
installcron = "(crontab -l | head -n6; echo \"*/5 * * * * python %s/deploy/mws3.cron\") | crontab -" % (filedir_path)
subprocess_cmd(installcron)
print "installed cron"



Expand Down
8 changes: 7 additions & 1 deletion edpcmentoring/edpcmentoring/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,17 @@
# Uncomment to activate the email notifications
# PS you may wish to update user record emails to test messages: update auth_user set email = concat('crsid+',username.'@cam.ac.uk')
#PINAX_NOTIFICATIONS_BACKENDS=[("email", "pinax.notifications.backends.email.EmailBackend"),]
# queue all notifications until emit_notices is called
#We can there for check for queued notifications and failed mail_logs (can we join the two?)
PINAX_NOTIFICATIONS_QUEUE_ALL=True
EMAIL_BACKEND = 'email_log.backends.EmailBackend'
EMAIL_SUBJECT_PREFIX = '[EDPC Mentoring] '
EMAIL_LOG_BACKEND = 'django.core.mail.backends.dummy.EmailBackend'
#EMAIL_LOG_BACKEND = 'django.core.mail.backends.dummy.EmailBackend'
DEFAULT_FROM_EMAIL = 'edpc-mentoring@eng.cam.ac.uk'

#exception info (eg failure to run emit_notices) emailed to:
ADMIN = [('S.Shorrock','sms67+edpc@cam.ac.uk'),('Mentoring App','edpc-mentoring@eng.cam.ac.uk')]

# Login URLs
LOGIN_URL = 'raven_login'
LOGIN_REDIRECT_URL = 'mentoring:index'
Expand Down

0 comments on commit 3cca5ec

Please sign in to comment.