Ran scripts invoked from bin/hourly and bin/daily through pyflakes3 and test invocation, and tweaked the code (with an added comment) to consistently require virtualenv to be set up before script invocation.

- Legacy-Id: 17269
This commit is contained in:
Henrik Levkowetz 2020-01-30 22:19:42 +00:00
parent 65ca6e240c
commit ac38dba94b
6 changed files with 44 additions and 26 deletions

View file

@ -1,6 +1,11 @@
#!/usr/bin/env python
import datetime, os, sys
# This script requires that the proper virtual python environment has been
# invoked before start
import datetime
import os
import sys
import syslog
# boilerplate
@ -17,6 +22,8 @@ syslog.openlog(os.path.basename(__file__), syslog.LOG_PID, syslog.LOG_USER)
import django
django.setup()
# ----------------------------------------------------------------------
from ietf.utils.log import logger
try:

View file

@ -1,6 +1,10 @@
#!/usr/bin/env python
import datetime, os, sys
# This script requires that the proper virtual python environment has been
# invoked before start
import os
import sys
import syslog
# boilerplate
@ -17,7 +21,9 @@ syslog.openlog(os.path.basename(__file__), syslog.LOG_PID, syslog.LOG_USER)
import django
django.setup()
from ietf.doc.lastcall import *
# ----------------------------------------------------------------------
from ietf.doc.lastcall import get_expired_last_calls, expire_last_call
drafts = get_expired_last_calls()
for doc in drafts:

View file

@ -1,6 +1,11 @@
#!/usr/bin/env python
import os, sys, re, json, datetime, optparse
# This script requires that the proper virtual python environment has been
# invoked before start
import datetime
import os
import sys
import syslog
# boilerplate
@ -8,10 +13,6 @@ 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))
import django
django.setup()
@ -47,8 +48,9 @@ if options.end:
syslog.openlog(os.path.basename(__file__), syslog.LOG_PID, syslog.LOG_USER)
# ----------------------------------------------------------------------
from ietf.sync.iana import *
from ietf.sync.iana import fetch_changes_json, parse_changes_json, update_history_with_changes
syslog.syslog("Updating history log with new changes from IANA from %s, period %s - %s" % (settings.IANA_SYNC_CHANGES_URL, start, end))

View file

@ -1,6 +1,11 @@
#!/usr/bin/env python
import os, sys, re, json, datetime
# This script requires that the proper virtual python environment has been
# invoked before start
import os
import sys
import datetime
import syslog
# boilerplate
@ -8,17 +13,13 @@ 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))
syslog.openlog(os.path.basename(__file__), syslog.LOG_PID, syslog.LOG_USER)
import django
django.setup()
from django.conf import settings
from ietf.sync.iana import *
from ietf.sync.iana import fetch_protocol_page, parse_protocol_page, update_rfc_log_from_protocol_page
def chunks(l, n):
"""Split list l up in chunks of max size n."""

View file

@ -1,9 +1,13 @@
#!/usr/bin/env python
# This script requires that the proper virtual python environment has been
# invoked before start
import datetime
import json
import os
import sys
import syslog
import traceback
from six.moves.urllib.request import urlopen
@ -13,9 +17,8 @@ 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
django.setup()

View file

@ -1,5 +1,9 @@
#!/usr/bin/env python
# This script requires that the proper virtual python environment has been
# invoked before start
import datetime
import os
import sys
import syslog
@ -9,18 +13,13 @@ 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):
with open(virtualenv_activation, 'rb') as f:
code = compile(f.read(), virtualenv_activation, 'exec')
exec(code, dict(__name__="__main__", __file__=virtualenv_activation))
# Before invoking django
syslog.openlog(os.path.basename(__file__), syslog.LOG_PID, syslog.LOG_USER)
import django
django.setup()
import datetime
from ietf.review.utils import (
review_assignments_needing_reviewer_reminder, email_reviewer_reminder,
review_assignments_needing_secretary_reminder, email_secretary_reminder,
@ -53,4 +52,4 @@ for msg in open_reviews_reminders_sent:
unconfirmed_assignment_reminders_sent = send_reminder_unconfirmed_assignments(today)
for msg in unconfirmed_assignment_reminders_sent:
log(msag)
log(msg)