Skip to content

Commit 09c891e

Browse files
committed
Added an utility script to extract information about the outgoing confirmation request email related to a draft submission.
- Legacy-Id: 4955
1 parent 554c3d7 commit 09c891e

1 file changed

Lines changed: 90 additions & 0 deletions

File tree

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#!/usr/bin/env python
2+
3+
import os
4+
import sys
5+
6+
version = "0.10"
7+
program = os.path.basename(sys.argv[0])
8+
progdir = os.path.dirname(sys.argv[0])
9+
10+
# assume we're placed in ietf/bin/:
11+
sys.path = [progdir+"/../../"] + sys.path
12+
os.environ["DJANGO_SETTINGS_MODULE"] = "ietf.settings"
13+
14+
# ----------------------------------------------------------------------
15+
def note(string):
16+
sys.stdout.write("%s\n" % (string))
17+
18+
# ----------------------------------------------------------------------
19+
def warn(string):
20+
sys.stderr.write(" * %s\n" % (string))
21+
22+
# ------------------------------------------------------------------------------
23+
24+
import re
25+
from datetime import datetime as Datetime
26+
import time
27+
import warnings
28+
warnings.filterwarnings('ignore', message='the sets module is deprecated', append=True)
29+
30+
from django.conf import settings
31+
32+
from ietf.utils.path import path as Path
33+
34+
from ietf.submit.models import IdSubmissionDetail
35+
from ietf.doc.models import Document
36+
37+
38+
39+
args = sys.argv[1:]
40+
if len(args) < 1:
41+
warn("Expected '$ %s DRAFTNAME', but found no arguments -- exiting" % program)
42+
sys.exit(1)
43+
44+
draft = args[0]
45+
if re.search("\.txt$", draft):
46+
draft = draft[:-4]
47+
if re.search("-\d\d$", draft):
48+
draft = draft[:-3]
49+
50+
if len(args) == 1:
51+
logfiles = [ arg[1] ]
52+
else:
53+
logfiles = args[1:]
54+
55+
from_email = settings.IDSUBMIT_FROM_EMAIL
56+
if "<" in from_email:
57+
from_email = from_email.split("<")[1].split(">")[0]
58+
59+
submission = IdSubmissionDetail.objects.filter(filename=draft).order_by('-pk')[0]
60+
document = Document.objects.get(name=draft)
61+
emails = [ author.address for author in document.authors.all() ]
62+
63+
file = Path(settings.INTERNET_DRAFT_PATH) / ("%s-%s.txt"%(draft, submission.revision))
64+
65+
upload_time = time.localtime(file.mtime)
66+
timestr1 = time.strftime("%b %d %H:%M", upload_time)
67+
timestr2 = timestr1[:-1] + chr(((ord(timestr1[-1])-ord('0')+1)%10)+ord('0'))
68+
note("Looking for mail log lines timestamped %s, also checking %s ..." % (timestr1, timestr2))
69+
70+
for log in logfiles:
71+
note("\n Checking %s ...\n" % log)
72+
if log.endswith('.gz'):
73+
import gzip
74+
logfile = gzip.open(log)
75+
else:
76+
logfile = open(log)
77+
queue_ids = []
78+
for line in logfile:
79+
if line.startswith(timestr1) or line.startswith(timestr2):
80+
if from_email in line:
81+
for to_email in emails:
82+
if to_email in line:
83+
sys.stdout.write(line)
84+
if "queued_as:" in line:
85+
queue_ids += [ line.split("queued_as:")[1].split(",")[0] ]
86+
elif queue_ids:
87+
for qi in queue_ids:
88+
if qi in line:
89+
sys.stdout.write(line)
90+

0 commit comments

Comments
 (0)