mebo.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:python-mebo 作者: crlane 项目源码 文件源码
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.'))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号