Skip to content

Commit ebdad3a

Browse files
committed
Added charset decoding of data read from an urlopen() object in a few places, and removed some use-once functions that were now dead code.
- Legacy-Id: 17355
1 parent 4b35ee4 commit ebdad3a

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

ietf/sync/iana.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from ietf.doc.utils import add_state_change_event
2424
from ietf.person.models import Person
2525
from ietf.utils.mail import parseaddr
26+
from ietf.utils.text import decode
2627
from ietf.utils.timezone import local_timezone_to_utc, email_time_to_local_timezone, utc_to_local_timezone
2728

2829

@@ -31,7 +32,7 @@
3132

3233
def fetch_protocol_page(url):
3334
f = urlopen(settings.IANA_SYNC_PROTOCOLS_URL)
34-
text = force_str(f.read())
35+
text = decode(f.read())
3536
f.close()
3637
return text
3738

@@ -80,7 +81,7 @@ def fetch_changes_json(url, start, end):
8081
password = settings.IANA_SYNC_PASSWORD
8182
request.add_header("Authorization", "Basic %s" % force_str(base64.encodestring(smart_bytes("%s:%s" % (username, password)))).replace("\n", ""))
8283
f = urlopen(request)
83-
text = f.read()
84+
text = decode(f.read())
8485
f.close()
8586
return text
8687

ietf/sync/rfceditor.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import base64
88
import datetime
99
import re
10-
import socket
1110
import six
1211

1312
from six.moves.urllib.request import Request, urlopen
@@ -28,6 +27,7 @@
2827
from ietf.person.models import Person
2928
from ietf.utils.log import log
3029
from ietf.utils.mail import send_mail_text
30+
from ietf.utils.text import decode
3131

3232
#QUEUE_URL = "https://www.rfc-editor.org/queue2.xml"
3333
#INDEX_URL = "https://www.rfc-editor.org/rfc/rfc-index.xml"
@@ -45,10 +45,6 @@ def get_child_text(parent_node, tag_name):
4545
return '\n\n'.join(text)
4646

4747

48-
def fetch_queue_xml(url):
49-
socket.setdefaulttimeout(30)
50-
return urlopen(url)
51-
5248
def parse_queue(response):
5349
"""Parse RFC Editor queue XML into a bunch of tuples + warnings."""
5450

@@ -234,10 +230,6 @@ def update_drafts_from_queue(drafts):
234230
return changed, warnings
235231

236232

237-
def fetch_index_xml(url):
238-
socket.setdefaulttimeout(30)
239-
return urlopen(url)
240-
241233
def parse_index(response):
242234
"""Parse RFC Editor index XML into a bunch of tuples."""
243235

@@ -550,7 +542,7 @@ def post_approved_draft(url, name):
550542
text = error = ""
551543
try:
552544
f = urlopen(request, data=smart_bytes(urlencode({ 'draft': name })), timeout=20)
553-
text = f.read()
545+
text = decode(f.read())
554546
status_code = f.getcode()
555547
f.close()
556548
log("RFC-Editor notification result for draft '%s': %s:'%s'" % (name, status_code, text))

0 commit comments

Comments
 (0)