def _discover(self, network):
"""
Runs the discovery scan to find Mebo on your LAN
:param network: The IPv4 network netmask as a CIDR string. Example: 192.168.1.0/24
:returns: The IP address of the Mebo found on the LAN
:raises: `MeboDiscoveryError` if broadcast discovery times out or the API probe produces a 40X or 50x status code
"""
try:
print('Looking for Mebo...')
self._network = IPv4Network(network)
addr = self._network.broadcast_address.compressed
broadcast = self._get_broadcast(addr)
api_response = self._probe(broadcast.ip)
api_response.raise_for_status()
print('Mebo found at {}'.format(broadcast.ip))
return broadcast.ip
except (socket.timeout, HTTPError):
raise MeboDiscoveryError(('Unable to locate Mebo on the network.\n'
'\tMake sure it is powered on and connected to LAN.\n'
'\tIt may be necessary to power cycle the Mebo.'))
评论列表
文章目录