Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_send_magic_packet(sock):
"""
Test whether the magic packets are broadcasted to the specified network.
"""
send_magic_packet(
"133713371337", "00-00-00-00-00-00", ip_address="example.com", port=7
)
assert sock.mock_calls == [
call(socket.AF_INET, socket.SOCK_DGRAM),
call().__enter__(),
call().__enter__().setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1),
call().__enter__().connect(("example.com", 7)),
call()
.__enter__()
.send(
b"\xff\xff\xff\xff\xff\xff"
b"\x137\x137\x137"
b"\x137\x137\x137"
b"\x137\x137\x137"
b"\x137\x137\x137"
b"\x137\x137\x137"
sys.path.append('../')
from samsungtvws import SamsungTVWS
# Normal constructor
tv = SamsungTVWS('192.168.xxx.xxx')
# Autosave token to file
token_file = os.path.dirname(os.path.realpath(__file__)) + '/tv-token.txt'
tv = SamsungTVWS(host='192.168.xxx.xxx', token_file=token_file)
# Toggle power
tv.shortcuts().power()
# Power On
wakeonlan.send_magic_packet('CC:6E:A4:xx:xx:xx')
# Open web in browser
tv.open_browser('https://duckduckgo.com/')
# View installed apps (Spotify)
tv.app_list()
# Open apps (Spotify)
tv.run_app('3201606009684')
def turn_on(self, **kwargs):
"""Turn the device on."""
if self._broadcast_address:
wakeonlan.send_magic_packet(
self._mac_address, ip_address=self._broadcast_address
)
else:
wakeonlan.send_magic_packet(self._mac_address)
def wake_on_lan(target_mac: str):
send_magic_packet(target_mac)
def turn_on(self):
_LOGGER.debug("Sending WOL magic packet mac %s to wake device",
self._mac)
import wakeonlan
wakeonlan.send_magic_packet(self._mac)
def turn_on(self):
"""Turn the media player on."""
if self._mac:
wakeonlan.send_magic_packet(self._mac, ip_address=self._broadcast)
else:
self.send_key("KEY_POWERON")
def turn_on(self):
"""Turn the media player on."""
if self._mac:
wakeonlan.send_magic_packet(self._mac)
else:
self.send_key("KEY_POWERON")
def wakeonlan(self, broadcast='255.255.255.255'):
"""Start the device either via wakeonlan."""
if self.mac:
wakeonlan.send_magic_packet(self.mac, ip_address=broadcast)
def turn_on(self, **kwargs):
"""Turn the device on."""
if self._broadcast_address:
wakeonlan.send_magic_packet(
self._mac_address, ip_address=self._broadcast_address
)
else:
wakeonlan.send_magic_packet(self._mac_address)