summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConrad Kostecki <conikost@gentoo.org>2023-05-07 14:33:35 +0200
committerConrad Kostecki <conikost@gentoo.org>2023-05-07 14:34:10 +0200
commit2ca0c72fa042dc510f74b128fe513db0cb9a934c (patch)
treefecdc4dc81f072e635b2986c2d76f2426635f9a5 /net-analyzer
parentnet-ftp/lftp: drop ipv6 use flag (diff)
downloadgentoo-2ca0c72fa042dc510f74b128fe513db0cb9a934c.tar.gz
gentoo-2ca0c72fa042dc510f74b128fe513db0cb9a934c.tar.bz2
gentoo-2ca0c72fa042dc510f74b128fe513db0cb9a934c.zip
net-analyzer/speedtest-cli: switch to json serverlist
Closes: https://bugs.gentoo.org/904968 Signed-off-by: Conrad Kostecki <conikost@gentoo.org>
Diffstat (limited to 'net-analyzer')
-rw-r--r--net-analyzer/speedtest-cli/files/speedtest-cli-2.1.3-json-serverlist.patch88
-rw-r--r--net-analyzer/speedtest-cli/speedtest-cli-2.1.3-r2.ebuild (renamed from net-analyzer/speedtest-cli/speedtest-cli-2.1.3-r1.ebuild)2
2 files changed, 90 insertions, 0 deletions
diff --git a/net-analyzer/speedtest-cli/files/speedtest-cli-2.1.3-json-serverlist.patch b/net-analyzer/speedtest-cli/files/speedtest-cli-2.1.3-json-serverlist.patch
new file mode 100644
index 000000000000..455fd4bfd2eb
--- /dev/null
+++ b/net-analyzer/speedtest-cli/files/speedtest-cli-2.1.3-json-serverlist.patch
@@ -0,0 +1,88 @@
+diff --git a/speedtest.py b/speedtest.py
+index a33296d..e7490b1 100755
+--- a/speedtest.py
++++ b/speedtest.py
+@@ -20,6 +20,7 @@ import re
+ import csv
+ import sys
+ import math
++import json
+ import errno
+ import signal
+ import socket
+@@ -1250,10 +1251,7 @@ class Speedtest(object):
+ )
+
+ urls = [
+- '://www.speedtest.net/speedtest-servers-static.php',
+- 'http://c.speedtest.net/speedtest-servers-static.php',
+- '://www.speedtest.net/speedtest-servers.php',
+- 'http://c.speedtest.net/speedtest-servers.php',
++ "://www.speedtest.net/api/js/servers",
+ ]
+
+ headers = {}
+@@ -1296,53 +1294,31 @@ class Speedtest(object):
+ printer('Servers XML:\n%s' % serversxml, debug=True)
+
+ try:
+- try:
+- try:
+- root = ET.fromstring(serversxml)
+- except ET.ParseError:
+- e = get_exception()
+- raise SpeedtestServersError(
+- 'Malformed speedtest.net server list: %s' % e
+- )
+- elements = etree_iter(root, 'server')
+- except AttributeError:
+- try:
+- root = DOM.parseString(serversxml)
+- except ExpatError:
+- e = get_exception()
+- raise SpeedtestServersError(
+- 'Malformed speedtest.net server list: %s' % e
+- )
+- elements = root.getElementsByTagName('server')
+- except (SyntaxError, xml.parsers.expat.ExpatError):
++ elements = json.loads(serversxml)
++ except SyntaxError:
+ raise ServersRetrievalError()
+
+ for server in elements:
+- try:
+- attrib = server.attrib
+- except AttributeError:
+- attrib = dict(list(server.attributes.items()))
+-
+- if servers and int(attrib.get('id')) not in servers:
++ if servers and int(server.get('id')) not in servers:
+ continue
+
+- if (int(attrib.get('id')) in self.config['ignore_servers']
+- or int(attrib.get('id')) in exclude):
++ if (int(server.get('id')) in self.config['ignore_servers']
++ or int(server.get('id')) in exclude):
+ continue
+
+ try:
+ d = distance(self.lat_lon,
+- (float(attrib.get('lat')),
+- float(attrib.get('lon'))))
++ (float(server.get('lat')),
++ float(server.get('lon'))))
+ except Exception:
+ continue
+
+- attrib['d'] = d
++ server['d'] = d
+
+ try:
+- self.servers[d].append(attrib)
++ self.servers[d].append(server)
+ except KeyError:
+- self.servers[d] = [attrib]
++ self.servers[d] = [server]
+
+ break
+
diff --git a/net-analyzer/speedtest-cli/speedtest-cli-2.1.3-r1.ebuild b/net-analyzer/speedtest-cli/speedtest-cli-2.1.3-r2.ebuild
index 57075996b3fe..4fb0e2fc1022 100644
--- a/net-analyzer/speedtest-cli/speedtest-cli-2.1.3-r1.ebuild
+++ b/net-analyzer/speedtest-cli/speedtest-cli-2.1.3-r2.ebuild
@@ -19,6 +19,8 @@ KEYWORDS="amd64 ~arm ~arm64 ppc ppc64 x86"
DEPEND="dev-python/setuptools[${PYTHON_USEDEP}]"
RDEPEND="${DEPEND}"
+PATCHES=( "${FILESDIR}/${PN}-2.1.3-json-serverlist.patch" )
+
python_install_all() {
doman ${PN}.1
distutils-r1_python_install_all