Skip to content

Commit

Permalink
fix: speed-ookla fails in systemd environment
Browse files Browse the repository at this point in the history
bump version 0.0.1-rc.15 → 0.0.1-rc.16.

fixes #48
  • Loading branch information
jesteria committed May 5, 2023
1 parent c68589b commit 4fd7b79
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "netrics-measurements"
version = "0.0.1-rc.15"
version = "0.0.1-rc.16"
description = "The extensible network measurements framework"
license = "MIT"
authors = [
Expand Down
8 changes: 4 additions & 4 deletions readme.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ The one-liner below will install Netrics for the current user:

[source,sh]
----
curl -sL https://github.com/internet-equity/netrics/raw/0.0.1-rc.15/install.py | python3
curl -sL https://github.com/internet-equity/netrics/raw/0.0.1-rc.16/install.py | python3
----

To install Netrics system-wide you might use `sudo`:

[source,sh]
----
curl -sL https://github.com/internet-equity/netrics/raw/0.0.1-rc.15/install.py | sudo python3
curl -sL https://github.com/internet-equity/netrics/raw/0.0.1-rc.16/install.py | sudo python3
----

[TIP]
Expand All @@ -67,15 +67,15 @@ You may pass arguments to the installer – even in the above form – separated
[source,sh]
----
curl -sL https://github.com/internet-equity/netrics/raw/0.0.1-rc.15/install.py | python3 - --help
curl -sL https://github.com/internet-equity/netrics/raw/0.0.1-rc.16/install.py | python3 - --help
----
====

Alternatively, download the installer to interact with it:

[source,console]
----
curl -LO https://github.com/internet-equity/netrics/raw/0.0.1-rc.15/install.py
curl -LO https://github.com/internet-equity/netrics/raw/0.0.1-rc.16/install.py
python3 install.py --help
----
Expand Down
22 changes: 21 additions & 1 deletion src/netrics/measurement/ookla.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Measure Internet bandwidth, *etc*., via the Ookla speedtest CLI."""
import json
import re
import subprocess

from schema import Optional, Or, Schema
Expand Down Expand Up @@ -28,6 +29,13 @@
})


LICENSE_PATTERN = re.compile(
r'=+\n+You may only use this Speedtest software.+'
r'\n+License acceptance recorded.\s+Continuing.\s*',
re.DOTALL | re.I
)


@task.param.require(PARAMS)
@require_net
def main(params):
Expand Down Expand Up @@ -69,6 +77,18 @@ def main(params):
timeout=(params.timeout or None),
capture_output=True,
text=True,
#
# Ookla speedtest fails if HOME unset --
# as it _may_ be, _e.g._ under Systemd (see #48).
#
# Explicitly setting HOME empty sidesteps this behavior
# (and simply disables its functionality to record license
# acceptance to the user's HOME directory).
#
# (And speedtest apparently, correctly, requires no other
# envvars, at least.)
#
env={'HOME': ''},
)
except subprocess.TimeoutExpired as exc:
task.log.critical(
Expand All @@ -91,7 +111,7 @@ def main(params):
)
return task.status.no_host

if proc.stderr:
if proc.stderr and not LICENSE_PATTERN.fullmatch(proc.stderr):
task.log.error(
status=f'Error ({proc.returncode})',
stdout=proc.stdout,
Expand Down

0 comments on commit 4fd7b79

Please sign in to comment.