Skip to content

Commit ac38dba

Browse files
committed
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
1 parent 65ca6e2 commit ac38dba

6 files changed

Lines changed: 44 additions & 26 deletions

File tree

ietf/bin/expire-ids

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
#!/usr/bin/env python
22

3-
import datetime, os, sys
3+
# This script requires that the proper virtual python environment has been
4+
# invoked before start
5+
6+
import datetime
7+
import os
8+
import sys
49
import syslog
510

611
# boilerplate
@@ -17,6 +22,8 @@ syslog.openlog(os.path.basename(__file__), syslog.LOG_PID, syslog.LOG_USER)
1722
import django
1823
django.setup()
1924

25+
# ----------------------------------------------------------------------
26+
2027
from ietf.utils.log import logger
2128

2229
try:

ietf/bin/expire-last-calls

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#!/usr/bin/env python
22

3-
import datetime, os, sys
3+
# This script requires that the proper virtual python environment has been
4+
# invoked before start
5+
6+
import os
7+
import sys
48
import syslog
59

610
# boilerplate
@@ -17,7 +21,9 @@ syslog.openlog(os.path.basename(__file__), syslog.LOG_PID, syslog.LOG_USER)
1721
import django
1822
django.setup()
1923

20-
from ietf.doc.lastcall import *
24+
# ----------------------------------------------------------------------
25+
26+
from ietf.doc.lastcall import get_expired_last_calls, expire_last_call
2127

2228
drafts = get_expired_last_calls()
2329
for doc in drafts:

ietf/bin/iana-changes-updates

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
#!/usr/bin/env python
22

3-
import os, sys, re, json, datetime, optparse
3+
# This script requires that the proper virtual python environment has been
4+
# invoked before start
5+
6+
import datetime
7+
import os
8+
import sys
49
import syslog
510

611
# boilerplate
712
basedir = os.path.abspath(os.path.join(os.path.dirname(__file__), "../.."))
813
sys.path = [ basedir ] + sys.path
914
os.environ["DJANGO_SETTINGS_MODULE"] = "ietf.settings"
1015

11-
virtualenv_activation = os.path.join(basedir, "env", "bin", "activate_this.py")
12-
if os.path.exists(virtualenv_activation):
13-
execfile(virtualenv_activation, dict(__file__=virtualenv_activation))
14-
1516
import django
1617
django.setup()
1718

@@ -47,8 +48,9 @@ if options.end:
4748

4849
syslog.openlog(os.path.basename(__file__), syslog.LOG_PID, syslog.LOG_USER)
4950

51+
# ----------------------------------------------------------------------
5052

51-
from ietf.sync.iana import *
53+
from ietf.sync.iana import fetch_changes_json, parse_changes_json, update_history_with_changes
5254

5355
syslog.syslog("Updating history log with new changes from IANA from %s, period %s - %s" % (settings.IANA_SYNC_CHANGES_URL, start, end))
5456

ietf/bin/iana-protocols-updates

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
#!/usr/bin/env python
22

3-
import os, sys, re, json, datetime
3+
# This script requires that the proper virtual python environment has been
4+
# invoked before start
5+
6+
import os
7+
import sys
8+
import datetime
49
import syslog
510

611
# boilerplate
712
basedir = os.path.abspath(os.path.join(os.path.dirname(__file__), "../.."))
813
sys.path = [ basedir ] + sys.path
914
os.environ["DJANGO_SETTINGS_MODULE"] = "ietf.settings"
1015

11-
virtualenv_activation = os.path.join(basedir, "env", "bin", "activate_this.py")
12-
if os.path.exists(virtualenv_activation):
13-
execfile(virtualenv_activation, dict(__file__=virtualenv_activation))
14-
1516
syslog.openlog(os.path.basename(__file__), syslog.LOG_PID, syslog.LOG_USER)
1617

1718
import django
1819
django.setup()
1920

2021
from django.conf import settings
21-
from ietf.sync.iana import *
22+
from ietf.sync.iana import fetch_protocol_page, parse_protocol_page, update_rfc_log_from_protocol_page
2223

2324
def chunks(l, n):
2425
"""Split list l up in chunks of max size n."""

ietf/bin/rfc-editor-index-updates

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
#!/usr/bin/env python
22

3+
# This script requires that the proper virtual python environment has been
4+
# invoked before start
5+
36
import datetime
47
import json
58
import os
69
import sys
10+
import syslog
711
import traceback
812

913
from six.moves.urllib.request import urlopen
@@ -13,9 +17,8 @@ basedir = os.path.abspath(os.path.join(os.path.dirname(__file__), "../.."))
1317
sys.path = [ basedir ] + sys.path
1418
os.environ["DJANGO_SETTINGS_MODULE"] = "ietf.settings"
1519

16-
virtualenv_activation = os.path.join(basedir, "env", "bin", "activate_this.py")
17-
if os.path.exists(virtualenv_activation):
18-
execfile(virtualenv_activation, dict(__file__=virtualenv_activation))
20+
# Before invoking django
21+
syslog.openlog(os.path.basename(__file__), syslog.LOG_PID, syslog.LOG_USER)
1922

2023
import django
2124
django.setup()

ietf/bin/send-review-reminders

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/usr/bin/env python
22

3+
# This script requires that the proper virtual python environment has been
4+
# invoked before start
5+
6+
import datetime
37
import os
48
import sys
59
import syslog
@@ -9,18 +13,13 @@ basedir = os.path.abspath(os.path.join(os.path.dirname(__file__), "../.."))
913
sys.path = [ basedir ] + sys.path
1014
os.environ["DJANGO_SETTINGS_MODULE"] = "ietf.settings"
1115

12-
virtualenv_activation = os.path.join(basedir, "env", "bin", "activate_this.py")
13-
if os.path.exists(virtualenv_activation):
14-
with open(virtualenv_activation, 'rb') as f:
15-
code = compile(f.read(), virtualenv_activation, 'exec')
16-
exec(code, dict(__name__="__main__", __file__=virtualenv_activation))
17-
16+
# Before invoking django
1817
syslog.openlog(os.path.basename(__file__), syslog.LOG_PID, syslog.LOG_USER)
1918

2019
import django
2120
django.setup()
2221

23-
import datetime
22+
2423
from ietf.review.utils import (
2524
review_assignments_needing_reviewer_reminder, email_reviewer_reminder,
2625
review_assignments_needing_secretary_reminder, email_secretary_reminder,
@@ -53,4 +52,4 @@ for msg in open_reviews_reminders_sent:
5352

5453
unconfirmed_assignment_reminders_sent = send_reminder_unconfirmed_assignments(today)
5554
for msg in unconfirmed_assignment_reminders_sent:
56-
log(msag)
55+
log(msg)

0 commit comments

Comments
 (0)