diff options
author | 2024-05-27 20:47:13 +0200 | |
---|---|---|
committer | 2024-05-28 04:48:00 +0100 | |
commit | 55402ec0df846a42dba44c295b5761a770724ce8 (patch) | |
tree | bf4274ec7c7bdc6295cd2e6be6364c9ce8c2368b | |
parent | Rerun `pyupgrade` with `--py39-plus` (diff) | |
download | mirrorselect-55402ec0df846a42dba44c295b5761a770724ce8.tar.gz mirrorselect-55402ec0df846a42dba44c295b5761a770724ce8.tar.bz2 mirrorselect-55402ec0df846a42dba44c295b5761a770724ce8.zip |
sslfetch was a thin NIH wrapper around requests, and it is unmaintained.
Closes: https://bugs.gentoo.org/932145
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Closes: https://github.com/gentoo/mirrorselect/pull/1
Signed-off-by: Sam James <sam@gentoo.org>
-rw-r--r-- | mirrorselect/extractor.py | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/mirrorselect/extractor.py b/mirrorselect/extractor.py index 4598b8b..7326c86 100644 --- a/mirrorselect/extractor.py +++ b/mirrorselect/extractor.py @@ -27,8 +27,9 @@ Distributed under the terms of the GNU General Public License v2 import os +import requests + from mirrorselect.mirrorparser3 import MirrorParser3 -from sslfetch.connections import Connector from mirrorselect.version import version USERAGENT = "Mirrorselect-" + version @@ -103,21 +104,14 @@ class Extractor: self.output.print_info("Downloading a list of mirrors...\n") - # setup the ssl-fetch ouptut map - connector_output = { - "info": self.output.write, - "debug": self.output.write, - "error": self.output.print_err, - "kwargs-info": {"level": 2}, - "kwargs-debug": {"level": 2}, - "kwargs-error": {"level": 0}, - } - - fetcher = Connector(connector_output, self.proxies, USERAGENT) - success, mirrorlist, timestamp = fetcher.fetch_content(url, climit=60) - parser.parse(mirrorlist) - - if (not mirrorlist) or len(parser.tuples()) == 0: + response = requests.get(url, + timeout=60, + proxies=self.proxies, + headers={"User-Agent": USERAGENT}) + if response: + parser.parse(response.text) + + if len(parser.tuples()) == 0: self.output.print_err( "Could not get mirror list. " "Check your internet connection." ) |