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) return "\n".join(text)
async def run_speedtest(self) -> str | Any: async def run_speedtest(self) -> str | Any:
process = await asyncio.create_subprocess_exec( try:
"speedtest", "-f json", "--accept-license", process = await asyncio.create_subprocess_exec(
stdout=subprocess.PIPE, "speedtest", "-f json", "--accept-license",
stderr=subprocess.PIPE stdout=subprocess.PIPE,
) stderr=subprocess.PIPE
)
except FileNotFoundError:
return "Speedtest CLI is not installed."
stdout, stderr = await process.communicate() stdout, stderr = await process.communicate()
if process.returncode != 0: if process.returncode != 0:
return stderr.decode("utf-8") return stderr.decode("utf-8")