Fix wake_on_lan ping for Linux. (#6480)

This commit is contained in:
siebert 2017-03-08 05:57:35 +01:00 committed by Paulus Schoutsen
parent bb4f23f8e7
commit 2c5d3387f2

View File

@ -85,11 +85,11 @@ class WOLSwitch(SwitchDevice):
def update(self):
"""Check if device is on and update the state."""
if platform.system().lower() == 'windows':
ping_cmd = 'ping -n 1 -w {} {}'.format(
DEFAULT_PING_TIMEOUT * 1000, self._host)
ping_cmd = ['ping', '-n', '1', '-w',
str(DEFAULT_PING_TIMEOUT * 1000), self._host]
else:
ping_cmd = 'ping -c 1 -W {} {}'.format(
DEFAULT_PING_TIMEOUT, self._host)
ping_cmd = ['ping', '-c', '1', '-W',
str(DEFAULT_PING_TIMEOUT), self._host]
status = sp.call(ping_cmd, stdout=sp.DEVNULL)
self._state = not bool(status)