mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Remove Windows workarounds from ping (#64069)
This commit is contained in:
parent
abce453b5c
commit
0fa4f616ed
@ -6,7 +6,6 @@ from contextlib import suppress
|
|||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
import sys
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from icmplib import NameLookupError, async_ping
|
from icmplib import NameLookupError, async_ping
|
||||||
@ -205,16 +204,6 @@ class PingDataSubProcess(PingData):
|
|||||||
def __init__(self, hass, host, count, privileged) -> None:
|
def __init__(self, hass, host, count, privileged) -> None:
|
||||||
"""Initialize the data object."""
|
"""Initialize the data object."""
|
||||||
super().__init__(hass, host, count)
|
super().__init__(hass, host, count)
|
||||||
if sys.platform == "win32":
|
|
||||||
self._ping_cmd = [
|
|
||||||
"ping",
|
|
||||||
"-n",
|
|
||||||
str(self._count),
|
|
||||||
"-w",
|
|
||||||
"1000",
|
|
||||||
self._ip_address,
|
|
||||||
]
|
|
||||||
else:
|
|
||||||
self._ping_cmd = [
|
self._ping_cmd = [
|
||||||
"ping",
|
"ping",
|
||||||
"-n",
|
"-n",
|
||||||
@ -261,12 +250,6 @@ class PingDataSubProcess(PingData):
|
|||||||
pinger.returncode,
|
pinger.returncode,
|
||||||
)
|
)
|
||||||
|
|
||||||
if sys.platform == "win32":
|
|
||||||
match = WIN32_PING_MATCHER.search(
|
|
||||||
str(out_data).rsplit("\n", maxsplit=1)[-1]
|
|
||||||
)
|
|
||||||
rtt_min, rtt_avg, rtt_max = match.groups()
|
|
||||||
return {"min": rtt_min, "avg": rtt_avg, "max": rtt_max, "mdev": ""}
|
|
||||||
if "max/" not in str(out_data):
|
if "max/" not in str(out_data):
|
||||||
match = PING_MATCHER_BUSYBOX.search(
|
match = PING_MATCHER_BUSYBOX.search(
|
||||||
str(out_data).rsplit("\n", maxsplit=1)[-1]
|
str(out_data).rsplit("\n", maxsplit=1)[-1]
|
||||||
|
@ -6,7 +6,6 @@ from collections.abc import Awaitable, Callable
|
|||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
|
||||||
|
|
||||||
from icmplib import async_multiping
|
from icmplib import async_multiping
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
@ -50,9 +49,6 @@ class HostSubProcess:
|
|||||||
self.ip_address = ip_address
|
self.ip_address = ip_address
|
||||||
self.dev_id = dev_id
|
self.dev_id = dev_id
|
||||||
self._count = config[CONF_PING_COUNT]
|
self._count = config[CONF_PING_COUNT]
|
||||||
if sys.platform == "win32":
|
|
||||||
self._ping_cmd = ["ping", "-n", "1", "-w", "1000", ip_address]
|
|
||||||
else:
|
|
||||||
self._ping_cmd = ["ping", "-n", "-q", "-c1", "-W1", ip_address]
|
self._ping_cmd = ["ping", "-n", "-q", "-c1", "-W1", ip_address]
|
||||||
|
|
||||||
def ping(self):
|
def ping(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user