From d4e5b0bcfcc1a0018916a028dc092bb1e0a603df Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 9 Mar 2026 21:52:43 +0000 Subject: [PATCH 1/2] Add error handling for speedtest-cli failures speedtest-cli returns HTTP 403 in cloud/container environments where Speedtest.net blocks requests. The script now checks the return code and provides a clear error message instead of crashing on empty JSON. https://claude.ai/code/session_01H8Tjtsy6kYtj5mCzzQBaWR --- speedtest.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/speedtest.py b/speedtest.py index b66c759..71748c4 100644 --- a/speedtest.py +++ b/speedtest.py @@ -1,11 +1,21 @@ import subprocess import json import sqlite3 +import sys # Run speedtest-cli command and capture output as JSON -speedtest_output = subprocess.run( +result = subprocess.run( ["speedtest-cli", "--json"], capture_output=True, text=True -).stdout.strip() +) +speedtest_output = result.stdout.strip() + +if result.returncode != 0 or not speedtest_output: + print("speedtest-cli failed:", result.stderr.strip(), file=sys.stderr) + print( + "This typically happens in cloud/container environments where " + "Speedtest.net blocks requests (HTTP 403)." + ) + sys.exit(1) print(speedtest_output) From 77030ddb0d55bd594fb73eafcc858b45ad7f18e7 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 9 Mar 2026 21:53:22 +0000 Subject: [PATCH 2/2] Add __pycache__ to .gitignore https://claude.ai/code/session_01H8Tjtsy6kYtj5mCzzQBaWR --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 2c2ce2e..e301b3b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ .vscode -*.db \ No newline at end of file +*.db +__pycache__/ +*.pyc \ No newline at end of file