From 4795df7dcc451e2e8dbdfbe146f4adac7b24ab2d Mon Sep 17 00:00:00 2001 From: Seaswimmer Date: Sat, 25 May 2024 17:21:33 -0400 Subject: [PATCH] fix(speedtest): added a error message for if speedtest is not installed --- speedtest/speedtest.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/speedtest/speedtest.py b/speedtest/speedtest.py index 4d16bc2..ea1daa4 100644 --- a/speedtest/speedtest.py +++ b/speedtest/speedtest.py @@ -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")