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)
|
||||
|
||||
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")
|
||||
|
|
Loading…
Reference in a new issue