From 98b47cecbd211a3790e4b894a419640d01252292 Mon Sep 17 00:00:00 2001 From: tadly Date: Tue, 6 Feb 2018 01:04:31 +0100 Subject: [PATCH] Upgrade wakeonlan to 1.0.0 (#12190) --- .../components/media_player/panasonic_viera.py | 6 +++--- homeassistant/components/media_player/samsungtv.py | 6 +++--- homeassistant/components/media_player/webostv.py | 2 +- homeassistant/components/switch/wake_on_lan.py | 6 +++--- homeassistant/components/wake_on_lan.py | 8 ++++---- requirements_all.txt | 3 +-- requirements_test_all.txt | 3 +-- tests/components/switch/test_wake_on_lan.py | 12 ++++++------ 8 files changed, 22 insertions(+), 24 deletions(-) diff --git a/homeassistant/components/media_player/panasonic_viera.py b/homeassistant/components/media_player/panasonic_viera.py index 1a14ab0289b..21a897f4d35 100644 --- a/homeassistant/components/media_player/panasonic_viera.py +++ b/homeassistant/components/media_player/panasonic_viera.py @@ -19,7 +19,7 @@ from homeassistant.const import ( import homeassistant.helpers.config_validation as cv REQUIREMENTS = ['panasonic_viera==0.3', - 'wakeonlan==0.2.2'] + 'wakeonlan==1.0.0'] _LOGGER = logging.getLogger(__name__) @@ -72,9 +72,9 @@ class PanasonicVieraTVDevice(MediaPlayerDevice): def __init__(self, mac, name, remote): """Initialize the Panasonic device.""" - from wakeonlan import wol + import wakeonlan # Save a reference to the imported class - self._wol = wol + self._wol = wakeonlan self._mac = mac self._name = name self._muted = False diff --git a/homeassistant/components/media_player/samsungtv.py b/homeassistant/components/media_player/samsungtv.py index caf458edc69..4afd578211e 100644 --- a/homeassistant/components/media_player/samsungtv.py +++ b/homeassistant/components/media_player/samsungtv.py @@ -23,7 +23,7 @@ from homeassistant.const import ( import homeassistant.helpers.config_validation as cv from homeassistant.util import dt as dt_util -REQUIREMENTS = ['samsungctl==0.6.0', 'wakeonlan==0.2.2'] +REQUIREMENTS = ['samsungctl==0.6.0', 'wakeonlan==1.0.0'] _LOGGER = logging.getLogger(__name__) @@ -92,13 +92,13 @@ class SamsungTVDevice(MediaPlayerDevice): """Initialize the Samsung device.""" from samsungctl import exceptions from samsungctl import Remote - from wakeonlan import wol + import wakeonlan # Save a reference to the imported classes self._exceptions_class = exceptions self._remote_class = Remote self._name = name self._mac = mac - self._wol = wol + self._wol = wakeonlan # Assume that the TV is not muted self._muted = False # Assume that the TV is in Play mode diff --git a/homeassistant/components/media_player/webostv.py b/homeassistant/components/media_player/webostv.py index 2081fc95223..3ccd3c7dbe9 100644 --- a/homeassistant/components/media_player/webostv.py +++ b/homeassistant/components/media_player/webostv.py @@ -26,7 +26,7 @@ import homeassistant.helpers.config_validation as cv from homeassistant.helpers.script import Script import homeassistant.util as util -REQUIREMENTS = ['pylgtv==0.1.7', 'websockets==3.2', 'wakeonlan==0.2.2'] +REQUIREMENTS = ['pylgtv==0.1.7', 'websockets==3.2'] _CONFIGURING = {} # type: Dict[str, str] _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/switch/wake_on_lan.py b/homeassistant/components/switch/wake_on_lan.py index d94ff8c268b..ecaff14e2e2 100644 --- a/homeassistant/components/switch/wake_on_lan.py +++ b/homeassistant/components/switch/wake_on_lan.py @@ -15,7 +15,7 @@ import homeassistant.helpers.config_validation as cv from homeassistant.helpers.script import Script from homeassistant.const import (CONF_HOST, CONF_NAME) -REQUIREMENTS = ['wakeonlan==0.2.2'] +REQUIREMENTS = ['wakeonlan==1.0.0'] _LOGGER = logging.getLogger(__name__) @@ -53,7 +53,7 @@ class WOLSwitch(SwitchDevice): def __init__(self, hass, name, host, mac_address, off_action, broadcast_address): """Initialize the WOL switch.""" - from wakeonlan import wol + import wakeonlan self._hass = hass self._name = name self._host = host @@ -61,7 +61,7 @@ class WOLSwitch(SwitchDevice): self._broadcast_address = broadcast_address self._off_script = Script(hass, off_action) if off_action else None self._state = False - self._wol = wol + self._wol = wakeonlan @property def should_poll(self): diff --git a/homeassistant/components/wake_on_lan.py b/homeassistant/components/wake_on_lan.py index 7da0f3054f3..4e729c7ccc7 100644 --- a/homeassistant/components/wake_on_lan.py +++ b/homeassistant/components/wake_on_lan.py @@ -13,7 +13,7 @@ import voluptuous as vol from homeassistant.const import CONF_MAC import homeassistant.helpers.config_validation as cv -REQUIREMENTS = ['wakeonlan==0.2.2'] +REQUIREMENTS = ['wakeonlan==1.0.0'] DOMAIN = "wake_on_lan" _LOGGER = logging.getLogger(__name__) @@ -31,7 +31,7 @@ WAKE_ON_LAN_SEND_MAGIC_PACKET_SCHEMA = vol.Schema({ @asyncio.coroutine def async_setup(hass, config): """Set up the wake on LAN component.""" - from wakeonlan import wol + import wakeonlan @asyncio.coroutine def send_magic_packet(call): @@ -42,11 +42,11 @@ def async_setup(hass, config): mac_address, broadcast_address) if broadcast_address is not None: yield from hass.async_add_job( - partial(wol.send_magic_packet, mac_address, + partial(wakeonlan.send_magic_packet, mac_address, ip_address=broadcast_address)) else: yield from hass.async_add_job( - partial(wol.send_magic_packet, mac_address)) + partial(wakeonlan.send_magic_packet, mac_address)) hass.services.async_register( DOMAIN, SERVICE_SEND_MAGIC_PACKET, send_magic_packet, diff --git a/requirements_all.txt b/requirements_all.txt index de31e639102..935ba2c8fa3 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1213,9 +1213,8 @@ vultr==0.1.2 # homeassistant.components.wake_on_lan # homeassistant.components.media_player.panasonic_viera # homeassistant.components.media_player.samsungtv -# homeassistant.components.media_player.webostv # homeassistant.components.switch.wake_on_lan -wakeonlan==0.2.2 +wakeonlan==1.0.0 # homeassistant.components.sensor.waqi waqiasync==1.0.0 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index b4116a8b44c..f4a4e09b124 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -183,9 +183,8 @@ vultr==0.1.2 # homeassistant.components.wake_on_lan # homeassistant.components.media_player.panasonic_viera # homeassistant.components.media_player.samsungtv -# homeassistant.components.media_player.webostv # homeassistant.components.switch.wake_on_lan -wakeonlan==0.2.2 +wakeonlan==1.0.0 # homeassistant.components.cloud warrant==0.6.1 diff --git a/tests/components/switch/test_wake_on_lan.py b/tests/components/switch/test_wake_on_lan.py index 2c4be648c8c..d7945218e73 100644 --- a/tests/components/switch/test_wake_on_lan.py +++ b/tests/components/switch/test_wake_on_lan.py @@ -40,7 +40,7 @@ class TestWOLSwitch(unittest.TestCase): """Stop everything that was started.""" self.hass.stop() - @patch('wakeonlan.wol.send_magic_packet', new=send_magic_packet) + @patch('wakeonlan.send_magic_packet', new=send_magic_packet) @patch('subprocess.call', new=call) def test_valid_hostname(self): """Test with valid hostname.""" @@ -71,7 +71,7 @@ class TestWOLSwitch(unittest.TestCase): state = self.hass.states.get('switch.wake_on_lan') self.assertEqual(STATE_ON, state.state) - @patch('wakeonlan.wol.send_magic_packet', new=send_magic_packet) + @patch('wakeonlan.send_magic_packet', new=send_magic_packet) @patch('subprocess.call', new=call) @patch('platform.system', new=system) def test_valid_hostname_windows(self): @@ -97,7 +97,7 @@ class TestWOLSwitch(unittest.TestCase): state = self.hass.states.get('switch.wake_on_lan') self.assertEqual(STATE_ON, state.state) - @patch('wakeonlan.wol.send_magic_packet', new=send_magic_packet) + @patch('wakeonlan.send_magic_packet', new=send_magic_packet) @patch('subprocess.call', new=call) def test_minimal_config(self): """Test with minimal config.""" @@ -108,7 +108,7 @@ class TestWOLSwitch(unittest.TestCase): } })) - @patch('wakeonlan.wol.send_magic_packet', new=send_magic_packet) + @patch('wakeonlan.send_magic_packet', new=send_magic_packet) @patch('subprocess.call', new=call) def test_broadcast_config(self): """Test with broadcast address config.""" @@ -126,7 +126,7 @@ class TestWOLSwitch(unittest.TestCase): switch.turn_on(self.hass, 'switch.wake_on_lan') self.hass.block_till_done() - @patch('wakeonlan.wol.send_magic_packet', new=send_magic_packet) + @patch('wakeonlan.send_magic_packet', new=send_magic_packet) @patch('subprocess.call', new=call) def test_off_script(self): """Test with turn off script.""" @@ -165,7 +165,7 @@ class TestWOLSwitch(unittest.TestCase): self.assertEqual(STATE_OFF, state.state) assert len(calls) == 1 - @patch('wakeonlan.wol.send_magic_packet', new=send_magic_packet) + @patch('wakeonlan.send_magic_packet', new=send_magic_packet) @patch('subprocess.call', new=call) @patch('platform.system', new=system) def test_invalid_hostname_windows(self):