fix(speedtest): added a error message for if speedtest is not installed
This commit is contained in:
parent
14dfafea2a
commit
4795df7dcc
1 changed files with 8 additions and 5 deletions
|
@ -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")
|
||||||
|
|
Loading…
Reference in a new issue