mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 10:17:09 +00:00
check for error while running speedtest (#2643)
This commit is contained in:
parent
ec8802ec44
commit
bce4be88dc
@ -7,7 +7,7 @@ https://home-assistant.io/components/sensor.speedtest/
|
|||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
from subprocess import check_output
|
from subprocess import check_output, CalledProcessError
|
||||||
|
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
from homeassistant.components.sensor import DOMAIN
|
from homeassistant.components.sensor import DOMAIN
|
||||||
@ -112,9 +112,13 @@ class SpeedtestData(object):
|
|||||||
import speedtest_cli
|
import speedtest_cli
|
||||||
|
|
||||||
_LOGGER.info('Executing speedtest')
|
_LOGGER.info('Executing speedtest')
|
||||||
|
try:
|
||||||
re_output = _SPEEDTEST_REGEX.split(
|
re_output = _SPEEDTEST_REGEX.split(
|
||||||
check_output([sys.executable, speedtest_cli.__file__,
|
check_output([sys.executable, speedtest_cli.__file__,
|
||||||
'--simple']).decode("utf-8"))
|
'--simple']).decode("utf-8"))
|
||||||
|
except CalledProcessError as process_error:
|
||||||
|
_LOGGER.error('Error executing speedtest: %s', process_error)
|
||||||
|
return
|
||||||
self.data = {'ping': round(float(re_output[1]), 2),
|
self.data = {'ping': round(float(re_output[1]), 2),
|
||||||
'download': round(float(re_output[2]), 2),
|
'download': round(float(re_output[2]), 2),
|
||||||
'upload': round(float(re_output[3]), 2)}
|
'upload': round(float(re_output[3]), 2)}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user