예제 #1
0
 def collectLogcat(self,filePath):
     cmd = "logcat"
     logcatContent = command.executeCommandOnDevice(cmd)
     if logcatContent is not None:
         self.writeToFile(filePath,logcatContent,'w')
     else:
         print("logcat is not collected properly")
예제 #2
0
 def collectDmesgLogs(self,filePath):
     cmd = "shell dmesg"
     fileContent = command.executeCommandOnDevice(cmd)
     if fileContent is not None:
         self.writeToFile(filePath,fileContent)
     else:
         print("dmesg log is not collected properly")
예제 #3
0
 def getDeviceID(self):
     deviceId = None
     cmd = "devices"
     output = command.executeCommandOnDevice(cmd)
     if output is not None:
         for line in output.splitlines():
             reObj = re.search(r'(\w+).*device\b', line)
             if reObj:
                 deviceId = reObj.group(1).strip()
     return deviceId
예제 #4
0
 def getDeviceProperty(self,property):
     cmd = "shell getprop"
     output = command.executeCommandOnDevice(cmd)
     if output is not None:
         lines = output.splitlines()
         for line in lines:
             if property in line:
                 (key,value) = line.split(':')
                 patternObj = re.search(r'\[(.*)\]',value)
                 if patternObj:
                     return patternObj.group(1)
     else:
         print("property is not found in getprop list")
         return None
예제 #5
0
 def deleteResourceFromDevice(self,resourcePath):
     cmd = "shell rm -rf {}".format(resourcePath)
     command.executeCommandOnDevice(cmd)
예제 #6
0
 def doesResourceExists(self, filePath):
     cmd = "ls {}".format(filePath)
     output = command.executeCommandOnDevice(cmd)
     if 'No such file or directory' in output:
         return False
     return True
예제 #7
0
 def unInstallApp(self, packageName):
     cmd = "uninstall {}".format(packageName)
     command.executeCommandOnDevice(cmd)
예제 #8
0
 def installApp(self,apkPath):
     cmd = "install -r -g {}".format(apkPath)
     command.executeCommandOnDevice(cmd)
예제 #9
0
 def reboot(self):
     cmd = "reboot"
     command.executeCommandOnDevice(cmd)
예제 #10
0
 def pullFiles(self,source,destination):
     if self.doesResourceExists(source):
         cmd = "pull {} {}".format(source,destination)
         command.executeCommandOnDevice(cmd)
     else:
         print("Resource doesn't exists on the device, Hence pulling failed")
예제 #11
0
 def pushFiles(self,source,destination):
     cmd = "push {} {}".format(source,destination)
     command.executeCommandOnDevice(cmd)
예제 #12
0
 def remount(self):
     cmd = "remount"
     command.executeCommandOnDevice(cmd)
예제 #13
0
 def getInstalledApps(self):
     cmd = "shell pm list packages"
     packageList = command.executeCommandOnDevice(cmd)
     if packageList is not None:
         return packageList
예제 #14
0
 def scrollDown(self,speed=60):
     x1, y1 = self.getCoOrdinates(50, 25)
     x2, y2 = self.getCoOrdinates(50, 75)
     cmd = "shell input touchscreen swipe {} {} {} {} {}".format(x1,y1,x2,y2,speed)
     command.executeCommandOnDevice(cmd)
예제 #15
0
 def captureScreenshot(self,imageFileName):
     imageFilePath = "/scard/{}".format(imageFileName)
     cmd = "shell screencap -p {}".format(imageFilePath)
     command.executeCommandOnDevice(cmd)
예제 #16
0
 def startCollectLogcat(self, filePath):
     cmd = "logcat -c"
     command.executeCommandOnDevice(cmd)
     logcatPid = self.collectLogcat(filePath)
     if logcatPid is not None:
         return logcatPid