simple network logging app

This commit is contained in:
2025-05-04 22:38:47 +02:00
commit 25f016595f
9 changed files with 371 additions and 0 deletions

24
run_speedtest.py Executable file
View File

@@ -0,0 +1,24 @@
#! /Users/cato/Code/Cato447/speed-logger/.venv/bin/python3
from cfspeedtest import CloudflareSpeedtest
from db import init_db, insert_result
from getmac import get_mac_address
from config import ROUTER_MAC
def run_test_and_save():
if get_mac_address(ip="192.168.0.1") != ROUTER_MAC:
print(get_mac_address(ip="192.168.0.1"), ROUTER_MAC)
print("Not connected to home network")
return
try:
tester = CloudflareSpeedtest()
results = tester.run_all(megabits=True) # returns SuiteResults
except Exception:
results = None # Trigger a failed test record
init_db()
insert_result(results)
print("==== Running Speedtest ====")
run_test_and_save()
print("==== Speedtest ended ====")