def _Discover(self): """Use multicast to discover stations on the local network.""" responses = multicast.send(PING_STRING, FLAGS.discovery_address, FLAGS.discovery_port, FLAGS.discovery_ttl) for host, response in responses: try: port = json.loads(response)[PING_RESPONSE_KEY] self._Track(host, port) except (KeyError, ValueError): _LOG.warning("Ignoring unrecognized discovery response from %s: %s" % (host, response))
def discover(cls, timeout_s=3): """Discover Stations, yielding them as they're found.""" for host, response in multicast.send(conf.station_discovery_string, timeout_s=timeout_s, **MULTICAST_KWARGS()): try: response = json.loads(response) port = response.pop("station_api_port") yield cls(host, port, StationInfo(**response)) except ValueError: _LOG.debug("Received malformed JSON from %s: %s", host, response) except TypeError: _LOG.debug("Received invalid discovery response from %s: %s", host, response, exc_info=True)
def discover(cls, timeout_s=3): """Discover Stations, yielding them as they're found.""" for host, response in multicast.send(conf.station_discovery_string, timeout_s=timeout_s, **MULTICAST_KWARGS()): try: response = json.loads(response) port = response.pop('station_api_port') yield cls(host, port, StationInfo(**response)) except ValueError: _LOG.debug('Received malformed JSON from %s: %s', host, response) except TypeError: _LOG.debug('Received invalid discovery response from %s: %s', host, response, exc_info=True)
def _discover(**kwargs): """Yields info about station servers announcing themselves via multicast.""" query = station_server.MULTICAST_QUERY for host, response in multicast.send(query, **kwargs): try: result = json.loads(response) except ValueError: _LOG.warn('Received bad JSON over multicast from %s: %s', host, response) try: yield StationInfo(result['cell'], host, result['port'], result['station_id'], 'ONLINE', result.get('test_description'), result['test_name']) except KeyError: if 'last_activity_time_millis' in result: _LOG.debug('Received old station API response on multicast. Ignoring.') else: _LOG.warn('Received bad multicast response from %s: %s', host, response)