def wait_for_ip_stack(self, timeout=5): """ :param timeout: (Default value = 5) """ eggtimer = Eggtimer(duration=timeout) log.info('Waiting for the network stack to come up within %s seconds', timeout) while not eggtimer.expired(): self.device.watchdog.feed() try: socket.getaddrinfo("localhost", 333) log.info('Network stack ready') return True except OSError as ex: #log.warning('Network stack not available: %s', format_exception(ex)) pass # Report about progress. sys.stderr.write('.') #sys.stderr.flush() # Save power while waiting. machine.idle() time.sleep(0.25) # TODO: Make WiFi-agnostic. raise NetworkUnavailable('Could not connect to WiFi network')
def wait_for_nic(self, timeout=5): """ :param timeout: (Default value = 5) """ eggtimer = Eggtimer(duration=timeout) log.info('Waiting for network interface') while not eggtimer.expired(): self.device.watchdog.feed() try: # TODO: Make WiFi-agnostic. if self.wifi_manager.is_connected(): log.info('Network interface ready') return True except OSError as ex: log.warning('Network interface not available: %s', format_exception(ex)) # Report about progress. sys.stderr.write('.') #sys.stderr.flush() # Save power while waiting. machine.idle() time.sleep(0.25) # TODO: Make WiFi-agnostic. raise NetworkUnavailable('Could not connect to WiFi network')