Add Speedtest cog #28

Open
cswimr wants to merge 17 commits from speedtest into main
Showing only changes of commit 4795df7dcc - Show all commits

View file

@ -36,11 +36,14 @@ class Speedtest(commands.Cog):
return "\n".join(text)
async def run_speedtest(self) -> str | Any:
process = await asyncio.create_subprocess_exec(
"speedtest", "-f json", "--accept-license",
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)
try:
process = await asyncio.create_subprocess_exec(
"speedtest", "-f json", "--accept-license",
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)
except FileNotFoundError:
return "Speedtest CLI is not installed."
stdout, stderr = await process.communicate()
if process.returncode != 0:
return stderr.decode("utf-8")