From f3098acc9adb239120f5903a95a1297a5387fff0 Mon Sep 17 00:00:00 2001 From: James Taliaferro Date: Aug 02 2024 00:18:55 +0000 Subject: Fetch repository metadata using urlopen instead of requests --- diff --git a/util/kojira b/util/kojira index 5e98f39..d0b2703 100755 --- a/util/kojira +++ b/util/kojira @@ -33,11 +33,11 @@ import time import traceback from optparse import OptionParser, SUPPRESS_HELP from xml.etree import ElementTree +from urllib.request import urlopen +from urllib.error import HTTPError from collections import OrderedDict -import requests - import koji from koji.util import deprecated, parseStatus, rmtree, to_list, dslice @@ -388,15 +388,14 @@ class RepoManager(object): continue self.logger.debug('Checking external url: %s' % arch_url) try: - r = requests.get(arch_url, timeout=5) - r.raise_for_status() - root = ElementTree.fromstring(r.text) # nosec + response = urlopen(arch_url, None, 5) + root = ElementTree.parse(response) ts_elements = root.iter('{http://linux.duke.edu/metadata/repo}timestamp') arch_ts = max([round(float(child.text)) for child in ts_elements]) ts_cache[arch_url] = arch_ts new_ts = max(new_ts, arch_ts) - except requests.exceptions.HTTPError as e: - if e.response.status_code == 404: + except HTTPError as e: + if e.code == 404: # we check all hub arches, so this can happen pretty easily # we'll warn below if _no_ arches give us a timestamp self.logger.debug("External repo url not found: %s", arch_url)