You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Leaving aside how to get fast-cli installed in the container for a moment, you would need to replace the command in take_measurement and the JSON parser in parse_measurement. The latter should output a dict with the fieldnames from speedtest-cli's CSV output, so the rest of the application can remain unchanged.
This is untested and just a quick draft, but:
# take a new measurement with fast-clideftake_measurement_fastcli(attempt=0):
cmd= ["fast", "--upload", "--json"]
now=utcnow().isoformat()
res=run(cmd)
ifres.returncode!=0:
stderr=res.stderr.decode()
ifattempt<3:
# silently retry after a momenttime.sleep(15)
returntake_measurement_fastcli(attempt+1)
else:
raiseSpeedTestError(stderr)
r=parse_measurement_fastcli(json.loads(res.stdout), now)
table.insert(r)
print(r)
# column names in speedtest-cli csv outputFIELDNAMES= ("Server ID", "Sponsor", "Server Name", "Timestamp", "Distance",
"Ping", "Download", "Upload", "Share", "IP Address")
# parse the json output of sindresorhus/fast-clidefparse_measurement_fastcli(js, now=utcnow().isoformat()):
# TODO: does fast have an error prop?if (err:=js.get("error")) isnotNone:
raiseSpeedTestError(err)
returndict(zip(FIELDNAMES, (
"fast.com",
"fast.com",
"fast.com",
now,
"",
js["latency"],
js["downloadSpeed"],
js["uploadSpeed"],
"",
js["userIp"],
)))
There's a few more places that reference the speedtest.net network of course but this might get you started.
Thanks for your time, I'm curious how difficult it would be to adapt this to fast-cli?
I'm looking inside the code but I doubt I come anywhere near close to the skills to convert it.
The text was updated successfully, but these errors were encountered: