commit:     55402ec0df846a42dba44c295b5761a770724ce8
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon May 27 18:47:13 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue May 28 03:48:00 2024 +0000
URL:        https://gitweb.gentoo.org/proj/mirrorselect.git/commit/?id=55402ec0

extractor.py: Replace sslfetch with plain requests

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 <AT> gentoo.org>
Closes: https://github.com/gentoo/mirrorselect/pull/1
Signed-off-by: Sam James <sam <AT> gentoo.org>

 mirrorselect/extractor.py | 26 ++++++++++----------------
 1 file 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."
             )

Reply via email to