silence error???

This commit is contained in:
Cyberes 2023-04-21 23:54:20 -06:00
parent 08c06777d6
commit dfc77a2f4d
1 changed files with 11 additions and 1 deletions

View File

@ -2,6 +2,7 @@
import argparse
import sys
import traceback
import warnings
from cloudflarepycli import cloudflareclass
@ -22,7 +23,16 @@ def main():
parser.add_argument('--critical-latency', type=int, default=100, help='Critical level of latency in ms.')
args = parser.parse_args()
speedtest_results = cloudflareclass.cloudflare(printit=False).runalltests()
# Silence this error:
"""
lib/python3.10/site-packages/numpy/core/fromnumeric.py:3464: RuntimeWarning: Mean of empty slice.
return _methods._mean(a, axis=axis, dtype=dtype,
lib/python3.10/site-packages/numpy/core/_methods.py:192: RuntimeWarning: invalid value encountered in scalar divide
ret = ret.dtype.type(ret / rcount)
"""
with warnings.catch_warnings():
warnings.simplefilter("ignore", category=RuntimeWarning)
speedtest_results = cloudflareclass.cloudflare(printit=False).runalltests()
out_str = f"upload: {speedtest_results['90th_percentile_upload_speed']['value']} Mbps, download: {speedtest_results['90th_percentile_download_speed']['value']} Mbps, latency: {speedtest_results['latency_ms']['value']} ms, Jitter: {speedtest_results['Jitter_ms']['value']} ms"
perf_data = f"'upload'={speedtest_results['90th_percentile_upload_speed']['value'] * 1e+6}B;{args.warn_up * 1e+6};{args.critical_up * 1e+6};0; 'download'={speedtest_results['90th_percentile_download_speed']['value'] * 1e+6}B;{args.warn_down * 1e+6};{args.critical_down * 1e+6};0; 'latency_ms'={speedtest_results['latency_ms']['value']}ms;{args.warn_latency};{args.critical_latency};0; 'Jitter_ms'={speedtest_results['Jitter_ms']['value']}ms;;;0;"