Passing error messages to log file

This commit is contained in:
M madrigal 2025-10-17 09:55:44 -04:00
parent 5cace9c15c
commit 9248549744

View File

@ -91,10 +91,12 @@ def collect_iperf(
if result.returncode != 0: if result.returncode != 0:
print(f"Error running iperf3: {result.stderr}") print(f"Error running iperf3: {result.stderr}")
output = "" output = ""
error = result.stderr
except subprocess.TimeoutExpired: except subprocess.TimeoutExpired:
print(f"iPerf test timed out after {timeout} seconds.") print(f"iPerf test timed out after {timeout} seconds.")
output = "" output = ""
error = f"iPerf test timed out after {timeout} seconds."
sender_bitrate, receiver_bitrate = parse_iperf_output(output) sender_bitrate, receiver_bitrate = parse_iperf_output(output)
@ -113,7 +115,7 @@ def collect_iperf(
"stations": stations, "stations": stations,
} }
if output == "": if output == "":
data["error"] = f"Test exceeded timeout of {timeout}s" data["error"] = error
else: else:
print(f"\n{server_ip} {test_type} IPERF complete") print(f"\n{server_ip} {test_type} IPERF complete")
print(f"IPERF sender bitrate: {sender_bitrate}") print(f"IPERF sender bitrate: {sender_bitrate}")