chore: remove more tools.ietf.org server only related things. (#4103)

* chore: remove more tools.ietf.org server only related things.

* chore: remove use of tools.ietf.org floorplans\n\nThe data will move into the FloorPlan models instead.
This commit is contained in:
Robert Sparks 2022-06-22 14:11:46 -05:00 committed by GitHub
parent 7da2795565
commit 10396d6f01
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 33 additions and 103 deletions

View file

@ -1,4 +1,4 @@
# Copyright The IETF Trust 2007-2020, All Rights Reserved
# Copyright The IETF Trust 2007-2022, All Rights Reserved
# -*- coding: utf-8 -*-
@ -460,7 +460,7 @@ def by_draft_txt(request):
def by_draft_recursive_txt(request):
"""Returns machine-readable list of IPR disclosures by draft name, recursive.
NOTE: this view is expensive and should be removed once tools.ietf.org is retired,
NOTE: this view is expensive and should be removed _after_ tools.ietf.org is retired,
including util function and management commands that generate the content for
this view."""
@ -856,4 +856,4 @@ def update(request, id):
ipr = get_object_or_404(IprDisclosureBase,id=id)
child = ipr.get_child()
type = class_to_type[child.__class__.__name__]
return new(request, type, updates=id)
return new(request, type, updates=id)

View file

@ -456,8 +456,6 @@ class Room(models.Model):
mtg_num = self.meeting.get_number()
if not mtg_num:
return None
elif mtg_num <= settings.FLOORPLAN_LAST_LEGACY_MEETING:
base_url = settings.FLOORPLAN_LEGACY_BASE_URL.format(meeting=self.meeting)
elif self.floorplan:
base_url = urlreverse('ietf.meeting.views.floor_plan', kwargs=dict(num=mtg_num))
else:

View file

@ -1,4 +1,4 @@
# Copyright The IETF Trust 2007-2020, All Rights Reserved
# Copyright The IETF Trust 2007-2022, All Rights Reserved
# -*- coding: utf-8 -*-
@ -73,7 +73,7 @@ SERVER_EMAIL = 'Django Server <django-project@' + IETF_DOMAIN + '>'
DEFAULT_FROM_EMAIL = 'IETF Secretariat <ietf-secretariat-reply@' + IETF_DOMAIN + '>'
UTILS_ON_BEHALF_EMAIL = 'noreply@' + IETF_DOMAIN
UTILS_FROM_EMAIL_DOMAINS = [ 'ietf.org', 'iab.org', 'tools.ietf.org', ]
UTILS_FROM_EMAIL_DOMAINS = [ 'ietf.org', 'iab.org', ]
MANAGERS = ADMINS
@ -536,7 +536,6 @@ INTERNAL_IPS = (
IDTRACKER_BASE_URL = "https://datatracker.ietf.org"
RFCDIFF_BASE_URL = "https://www.ietf.org/rfcdiff"
IDNITS_BASE_URL = "https://www.ietf.org/tools/idnits"
XML2RFC_BASE_URL = "https://xml2rfc.tools.ietf.org/experimental.html"
# Content security policy configuration (django-csp)
CSP_DEFAULT_SRC = ("'self'", "'unsafe-inline'", f"data: {IDTRACKER_BASE_URL} https://www.ietf.org/ https://analytics.ietf.org/")
@ -867,7 +866,6 @@ IDSUBMIT_MAX_DAILY_SAME_GROUP_SIZE = 450 # in MB
IDSUBMIT_MAX_DAILY_SUBMISSIONS = 1000
IDSUBMIT_MAX_DAILY_SUBMISSIONS_SIZE = 2000 # in MB
XML_LIBRARY = "/www/tools.ietf.org/tools/xml2rfc/web/public/rfc/"
# === Meeting Related Settings =================================================
@ -961,8 +959,7 @@ INTERNET_DRAFT_DAYS_TO_EXPIRE = 185
FLOORPLAN_MEDIA_DIR = 'floor'
FLOORPLAN_DIR = os.path.join(MEDIA_ROOT, FLOORPLAN_MEDIA_DIR)
FLOORPLAN_LEGACY_BASE_URL = 'https://tools.ietf.org/agenda/{meeting.number}/venue/'
FLOORPLAN_LAST_LEGACY_MEETING = 95 # last meeting to use FLOORPLAN_LEGACY_BASE_URL
MEETING_USES_CODIMD_DATE = datetime.date(2020,7,6)
MEETING_LEGACY_OFFICE_HOURS_END = 112 # last meeting to use legacy office hours representation

View file

@ -1,4 +1,4 @@
# Copyright The IETF Trust 2011-2020, All Rights Reserved
# Copyright The IETF Trust 2011-2022, All Rights Reserved
# -*- coding: utf-8 -*-
@ -188,7 +188,6 @@ class SubmissionBaseUploadForm(forms.Form):
tfn = tf.name
for chunk in xml_file.chunks():
tf.write(chunk)
os.environ["XML_LIBRARY"] = settings.XML_LIBRARY
parser = xml2rfc.XmlRfcParser(str(tfn), quiet=True)
# --- Parse the xml ---
@ -668,4 +667,4 @@ class MessageModelForm(forms.ModelForm):
super(MessageModelForm, self).__init__(*args, **kwargs)
self.fields['frm'].label='From'
self.fields['frm'].widget.attrs['readonly'] = True
self.fields['reply_to'].widget.attrs['readonly'] = True
self.fields['reply_to'].widget.attrs['readonly'] = True

View file

@ -1,5 +1,5 @@
#!/usr/bin/python
# Copyright The IETF Trust 2009-2021, All Rights Reserved
# Copyright The IETF Trust 2009-2022, All Rights Reserved
# -*- coding: utf-8 -*-
# -*- python -*-
@ -63,7 +63,6 @@ opt_debug = False
opt_timestamp = False
opt_trace = False
opt_authorinfo = False
opt_getauthors = False
opt_attributes = False
# Don't forget to add the option variable to the globals list in _main below
@ -1243,28 +1242,6 @@ def getmeta(fn):
filename = fn
fn = os.path.basename(fn)
else:
if fn.lower().startswith('rfc'):
filename = os.path.join("/www/tools.ietf.org/rfc", fn)
elif not "/" in fn:
filename = os.path.join("/www/tools.ietf.org/id", fn)
if not os.path.exists(filename):
fn = filename
while not "-00." in fn:
revmatch = re.search(r"-(\d\d)\.", fn)
if revmatch:
rev = revmatch.group(1)
prev = "%02d" % (int(rev)-1)
fn = fn.replace("-%s."%rev, "-%s."%prev)
if os.path.exists(fn):
_warn("Using rev %s instead: '%s'" % (prev, filename))
filename = fn
fn = os.path.basename(fn)
break
else:
break
else:
filename = fn
if not os.path.exists(filename):
_warn("Could not find file: '%s'" % (filename))
return
@ -1305,52 +1282,28 @@ def getmeta(fn):
# ----------------------------------------------------------------------
def _output(docname, fields, outfile=sys.stdout):
global company_domain
if opt_getauthors:
# Output an (incomplete!) getauthors-compatible format.
# Information about security and iana sections presence is
# missing.
for full,first,middle,last,suffix,email,country,company in fields["_authorlist"]:
if company in company_domain:
company = company_domain[company]
else:
if email and '@' in email:
company = email.split('@')[1]
if company.endswith(".com"):
company = company[:-4]
fields["name"] = full
fields["email"] = email
fields["company"] = company
fields["country"] = country or "UNKNOWN"
try:
year, month, day = fields["doccreationdate"].split("-")
except ValueError:
year, month, day = "UNKNOWN", "UNKNOWN", "UNKNOWN"
fields["day"] = day
fields["month"] = month_names[int(month)] if month != "UNKNOWN" else "UNKNOWN"
fields["year"] = year
print("%(doctag)s:%(name)s:%(company)s:%(email)s:%(country)s:%(docpages)s:%(month)s:%(year)s:%(day)s:" % fields)
else:
if opt_attributes:
def outputkey(key, fields):
field = fields[key]
if "\n" in field:
field = "\n" + field.rstrip()
else:
field = field.strip()
outfile.write("%-24s: %s\n" % ( key, field.replace("\\", "\\\\" ).replace("'", "\\x27" )))
else:
def outputkey(key, fields):
outfile.write(" %s='%s'" % ( key.lower(), fields[key].strip().replace("\\", "\\\\" ).replace("'", "\\x27" ).replace("\n", "\\n")))
if opt_timestamp:
outfile.write("%s " % (fields["eventdate"]))
outfile.write("%s" % (os.path.basename(docname.strip())))
keys = list(fields.keys())
keys.sort()
for key in keys:
if fields[key] and not key in ["eventdate", ] and not key.startswith("_"):
outputkey(key, fields)
outfile.write("\n")
if opt_attributes:
def outputkey(key, fields):
field = fields[key]
if "\n" in field:
field = "\n" + field.rstrip()
else:
field = field.strip()
outfile.write("%-24s: %s\n" % ( key, field.replace("\\", "\\\\" ).replace("'", "\\x27" )))
else:
def outputkey(key, fields):
outfile.write(" %s='%s'" % ( key.lower(), fields[key].strip().replace("\\", "\\\\" ).replace("'", "\\x27" ).replace("\n", "\\n")))
if opt_timestamp:
outfile.write("%s " % (fields["eventdate"]))
outfile.write("%s" % (os.path.basename(docname.strip())))
keys = list(fields.keys())
keys.sort()
for key in keys:
if fields[key] and not key in ["eventdate", ] and not key.startswith("_"):
outputkey(key, fields)
outfile.write("\n")
# ----------------------------------------------------------------------
def _printmeta(fn, outfile=sys.stdout):
@ -1371,7 +1324,7 @@ def _printmeta(fn, outfile=sys.stdout):
company_domain = {} # type: Dict[str, str]
def _main(outfile=sys.stdout):
global opt_debug, opt_timestamp, opt_trace, opt_authorinfo, opt_getauthors, files, company_domain, opt_attributes
global opt_debug, opt_timestamp, opt_trace, opt_authorinfo, files, company_domain, opt_attributes
# set default values, if any
# ----------------------------------------------------------------------
# Option processing
@ -1408,8 +1361,6 @@ def _main(outfile=sys.stdout):
elif opt in ["-v", "--version"]: # Output version information, then exit
print(program, version)
sys.exit(0)
elif opt in ["--getauthors"]: # Output an (incomplete) getauthors-compatible format
opt_getauthors = True
elif opt in ["-a", "--attribs"]: # Output key-value attribute pairs
opt_attributes = True
elif opt in ["-t", ]: # Toggle leading timestamp information
@ -1422,15 +1373,7 @@ def _main(outfile=sys.stdout):
opt_trace = True
company_domain = {}
if opt_getauthors:
gadata = io.open("/www/tools.ietf.org/tools/getauthors/getauthors.data")
for line in gadata:
if line.startswith("company:"):
try:
kword, name, abbrev = line.strip().split(':')
company_domain[name] = abbrev
except ValueError:
pass
if not files:
files = [ "-" ]

View file

@ -1,4 +1,4 @@
# Copyright The IETF Trust 2021, All Rights Reserved
# Copyright The IETF Trust 2022, All Rights Reserved
# -*- coding: utf-8 -*-
import os
import xml2rfc
@ -7,8 +7,6 @@ import debug # pyflakes: ignore
from contextlib import ExitStack
from django.conf import settings
from .draft import Draft
@ -32,20 +30,15 @@ class XMLDraft(Draft):
def parse_xml(filename):
orig_write_out = xml2rfc.log.write_out
orig_write_err = xml2rfc.log.write_err
orig_xml_library = os.environ.get('XML_LIBRARY', None)
tree = None
with ExitStack() as stack:
@stack.callback
def cleanup(): # called when context exited, even if there's an exception
xml2rfc.log.write_out = orig_write_out
xml2rfc.log.write_err = orig_write_err
os.environ.pop('XML_LIBRARY')
if orig_xml_library is not None:
os.environ['XML_LIBRARY'] = orig_xml_library
xml2rfc.log.write_out = open(os.devnull, 'w')
xml2rfc.log.write_err = open(os.devnull, 'w')
os.environ['XML_LIBRARY'] = settings.XML_LIBRARY
parser = xml2rfc.XmlRfcParser(filename, quiet=True)
tree = parser.parse()