From 4b35ee43d2eca7079fd64a5615dca5feb0d085f1 Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz <henrik@levkowetz.com> Date: Thu, 27 Feb 2020 13:35:14 +0000 Subject: [PATCH] Moved code from a couple of simple urlopen() wrappers used only once into the calling scripts. Removed a case of Py2 virtualenv activation. - Legacy-Id: 17354 --- ietf/bin/rfc-editor-index-updates | 5 ++++- ietf/bin/rfc-editor-queue-updates | 14 +++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/ietf/bin/rfc-editor-index-updates b/ietf/bin/rfc-editor-index-updates index 734c811b9..e9ac43a6c 100755 --- a/ietf/bin/rfc-editor-index-updates +++ b/ietf/bin/rfc-editor-index-updates @@ -6,6 +6,7 @@ import datetime import json import os +import socket import sys import syslog import traceback @@ -46,7 +47,9 @@ if options.skip_date: log("Updating document metadata from RFC index from %s" % settings.RFC_EDITOR_INDEX_URL) -rfc_index_xml = ietf.sync.rfceditor.fetch_index_xml(settings.RFC_EDITOR_INDEX_URL) + +socket.setdefaulttimeout(30) +rfc_index_xml = urlopen(settings.RFC_EDITOR_INDEX_URL) index_data = ietf.sync.rfceditor.parse_index(rfc_index_xml) rfc_errata_json = urlopen(settings.RFC_EDITOR_ERRATA_JSON_URL) diff --git a/ietf/bin/rfc-editor-queue-updates b/ietf/bin/rfc-editor-queue-updates index 8b3707018..a279346c7 100755 --- a/ietf/bin/rfc-editor-queue-updates +++ b/ietf/bin/rfc-editor-queue-updates @@ -1,27 +1,27 @@ #!/usr/bin/env python -import os, sys +import os +import socket +import sys +from six.moves.urllib.request import urlopen # boilerplate 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() from django.conf import settings -from ietf.sync.rfceditor import fetch_queue_xml, parse_queue, MIN_QUEUE_RESULTS, update_drafts_from_queue +from ietf.sync.rfceditor import parse_queue, MIN_QUEUE_RESULTS, update_drafts_from_queue from ietf.utils.log import log log("Updating RFC Editor queue states from %s" % settings.RFC_EDITOR_QUEUE_URL) -response = fetch_queue_xml(settings.RFC_EDITOR_QUEUE_URL) +socket.setdefaulttimeout(30) +response = urlopen(settings.RFC_EDITOR_QUEUE_URL) drafts, warnings = parse_queue(response) for w in warnings: log(u"Warning: %s" % w)