def startReading(self, clear): if self._thread: raise RuntimeError('Attempting to start reading twice') if clear: ADB.clearLogcat() self._thread = LogcatDatabase.ReaderThread(self._dbPath) self._thread.start()
def restart(self): ''' Issue DUT reboot request, and wait for it to come online ''' ADB.reboot() sleep(3) self.waitUntilOnline()
def waitUntilOnline(self, numAttempts=5): ''' Wait until the DUT is online and operational ''' while not self.isOnline() and numAttempts > 0: sleep(3) ADB.disconnect() sleep(0.5) try: ADB.connect(self._ip) except CommandTimeoutException: pass numAttempts -= 1 return self.isOnline()
def isOnline(self): ''' Check if the DUT is online and operational ''' devices = ADB.onlineDevices() if not devices: return False for dev in devices: if self._ip in dev: # Execute simple echo command to verify that device is responding try: res = ADB.shell('echo 42') except CommandTimeoutException: return False return False if not res or res.rc != 0 else res.out.strip() == '42' return False