From ab40807c36f9996d5ca91447872db00343528bb3 Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Sun, 23 Feb 2020 16:22:40 +0000 Subject: [PATCH] Converted send-scheduled-mail to py3 - Legacy-Id: 17332 --- ietf/bin/send-scheduled-mail | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ietf/bin/send-scheduled-mail b/ietf/bin/send-scheduled-mail index 40cb632fa..c6a2dbf50 100755 --- a/ietf/bin/send-scheduled-mail +++ b/ietf/bin/send-scheduled-mail @@ -1,5 +1,8 @@ #!/usr/bin/env python +# This script requires that the proper virtual python environment has been +# invoked before start + import datetime, os, sys import syslog @@ -8,10 +11,7 @@ basedir = os.path.abspath(os.path.join(os.path.dirname(__file__), "../..")) sys.path = [ basedir ] + sys.path 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)) - +# Before invoking django syslog.openlog(os.path.basename(__file__), syslog.LOG_PID, syslog.LOG_USER) import django @@ -22,9 +22,9 @@ from smtplib import SMTPException if len(sys.argv) != 2 or sys.argv[1] not in ('all', 'rsync', 'specific'): - print "USAGE: %s " % os.path.basename(__file__) - print "'all' means all not sent" - print "'specific' means all not sent that are due to be sent" + print("USAGE: %s " % os.path.basename(__file__)) + print("'all' means all not sent") + print("'specific' means all not sent that are due to be sent") sys.exit(1) from ietf.message.utils import send_scheduled_message_from_send_queue @@ -41,7 +41,7 @@ if mode == "specific": for s in needs_sending: try: send_scheduled_message_from_send_queue(s) - syslog.syslog(u'Sent scheduled message %s "%s"' % (s.id, s.message.subject)) + syslog.syslog('Sent scheduled message %s "%s"' % (s.id, s.message.subject)) except SMTPException as e: log_smtp_exception(e) send_error_email(e)