fix(speedtest): added a error message for if speedtest is not installed

This commit is contained in:
Seaswimmer 2024-05-25 17:21:33 -04:00
parent 14dfafea2a
commit 4795df7dcc
Signed by untrusted user: cswimr
GPG key ID: 5D671B5D03D65A7F

View file

@ -36,11 +36,14 @@ class Speedtest(commands.Cog):
return "\n".join(text)
async def run_speedtest(self) -> str | Any:
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")