def getLog(self): """ Returns the (full) logcat output """ args = ['shell', 'logcat', '-d', '-v', 'thread', '&&', '%sadb' % Utils.getAdbPath(self.sdkPath), '-s', 'emulator-%s' % str(self.port), 'shell', 'logcat', '-b', 'events', '-d', '-v', 'thread', '&&', '%sadb' % Utils.getAdbPath(self.sdkPath), '-s', 'emulator-%s' % str(self.port), 'shell', 'logcat', '-b', 'radio', '-d', '-v', 'thread'] logcat = self.runAdbCommand(args)[0] return logcat
def startLogcatRedirect(self, theFile='/data/local/logcat.log', theMaxSize=4096): """ Start logcat redirection. """ self.log.info('Start logcat redirect, file: %s, size: %dkBytes' % (theFile, theMaxSize), setTime=True) if not self.logcatRedirectProcess is None: self.endLogcatRedirect() if not self.logcatRedirectProcess is None: raise EmulatorClientError('Logcat redirect is already running', EmulatorClientError.LOGCAT_REDIRECT_RUNNING) try: args = ['%s/adb' % Utils.getAdbPath(self.sdkPath), '-s', 'emulator-%s' % str(self.port), 'shell', 'logcat', '-v', 'thread', '-f', theFile, '-r', str(theMaxSize)] self.logcatRedirectProcess = subprocess.Popen(args, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE) #if self.verbose: # print self.logcatRedirectProcess.communicate() except OSError, osErr: raise EmulatorClientError('Failed to run adb command \'%s\': %s' % (args, osErr.strerror), theCode=EmulatorClientError.ADB_RUN_ERROR, theBaseError=osErr)
def runAdbCommand(self, theArgs): """ Runs a simple adb command """ args = ['%s/adb' % Utils.getAdbPath(self.sdkPath), '-s', 'emulator-%s' % str(self.port)] args.extend(theArgs) self.log.info('-Exec adb command: %s' % args, setTime=True) try: self.adbProcess = subprocess.Popen(args, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE) except OSError, osErr: raise EmulatorClientError('-Failed to run adb command \'%s\': %s' % (args, osErr.strerror), theCode=EmulatorClientError.ADB_RUN_ERROR, theBaseError=osErr)