From 296b126c706968388b6b6d601c24f45b7d10b242 Mon Sep 17 00:00:00 2001 From: Sasha Romijn Date: Thu, 5 Sep 2019 10:50:39 +0000 Subject: [PATCH] Ref #2231 - Fix send-review-reminders and add it to daily cron This fixes a syntax error and a Python 3 incompatibility, and adds send-review-reminders to the daily cron script. Important notes: - I have not tested to what degree the existing reminders work as they should, as that's out of scope. It does have tests. - I can't assess whether the virtualenv activation works in the production setup, and it may be obsolete as bin/daily also activates the virtualenv. - The same Python 3 incompatibility (execfile() no longer exists) seems to exist in various other scripts. Commit ready for merge. - Legacy-Id: 16703 --- bin/daily | 2 ++ ietf/bin/send-review-reminders | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/bin/daily b/bin/daily index 19ce475e0..289dace96 100755 --- a/bin/daily +++ b/bin/daily @@ -50,3 +50,5 @@ $DTDIR/ietf/bin/rfc-editor-index-updates -d 1969-01-01 # Fetch meeting attendance data from ietf.org/registration/attendees $DTDIR/ietf/manage.py fetch_meeting_attendance --latest 2 +# Send reminders originating from the review app +$DTDIR/ietf/bin/send-review-reminders diff --git a/ietf/bin/send-review-reminders b/ietf/bin/send-review-reminders index eb21325fa..1b7f2668c 100755 --- a/ietf/bin/send-review-reminders +++ b/ietf/bin/send-review-reminders @@ -1,6 +1,7 @@ #!/usr/bin/env python -import os, sys +import os +import sys import syslog # boilerplate @@ -10,7 +11,9 @@ os.environ["DJANGO_SETTINGS_MODULE"] = "ietf.settings" virtualenv_activation = os.path.join(basedir, "env", "bin", "activate_this.py") if os.path.exists(virtualenv_activation): - execfile(virtualenv_activation, dict(__file__=virtualenv_activation)) + with open(virtualenv_activation, 'rb') as f: + code = compile(f.read(), virtualenv_activation, 'exec') + exec(code, globals=dict(__name__="__main__", __file__=virtualenv_activation)) syslog.openlog(os.path.basename(__file__), syslog.LOG_PID, syslog.LOG_USER) @@ -27,11 +30,10 @@ today = datetime.date.today() for assignment in review_assignments_needing_reviewer_reminder(today): email_reviewer_reminder(assignment.review_request) - for review_assignment in assignments.review_req.reviewassignment_set.all(): + for review_assignment in assignment.review_req.reviewassignment_set.all(): print("Emailed reminder to {} for review of {} in {} (req. id {})".format(review_assignment.reviewer.address, assignment.review_req.doc_id, assignment.review_req.team.acronym, assignment.review_req.pk)) for assignment, secretary_role in review_assignments_needing_secretary_reminder(today): email_secretary_reminder(assignment.review_request, secretary_role) review_req = assignment.review_request print("Emailed reminder to {} for review of {} in {} (req. id {})".format(secretary_role.email.address, review_req.doc_id, review_req.team.acronym, review_req.pk)) -