def screenshot(): path = PATH("%s/screenshot" %os.getcwd()) utils.shell("screencap -p /data/local/tmp/tmp.png").wait() if not os.path.isdir("%s/screenshot" %PATH(os.getcwd())): os.makedirs(path) utils.adb("pull /data/local/tmp/tmp.png %s" %PATH("%s/%s.png" %(path, utils.timestamp()))).wait() utils.shell("rm /data/local/tmp/tmp.png")
def get_match_apk(package_name, path): list = [] for packages in utils.shell("pm list packages -f %s" %package_name).stdout.readlines(): if packages.split(":")[0] == "package": list.append(packages.split(":")[-1].split("=")[0]) utils.adb("pull %s %s" %(list[0], path)).wait()
def get_match_apk(package_name): list = [] for packages in utils.shell("pm list packages -f %s" %package_name).stdout.readlines(): list.append(packages.split(":")[-1].split("=")[0]) apk_name = list[0].split("/")[-1] utils.adb("pull %s %s" %(list[0], tempFile)).wait() return "%s\\%s" %(tempFile, apk_name)
def record(): utils.shell("screenrecord /data/local/tmp/video.mp4") input_key = raw_input("Please press the Enter key to stop recording:\n") if input_key == "": utils.adb("kill-server") print "Get Video file..." path = PATH("%s/video" %os.getcwd()) if not os.path.isdir(path): os.makedirs(path) utils.adb("pull /data/local/tmp/video.mp4 %s" %PATH("%s/%s.mp4" %(path, utils.timestamp()))).wait()
def record(): utils.shell("screenrecord /data/local/tmp/video.mp4") input_key = raw_input("Please press the Enter key to stop recording:\n") if input_key == "": utils.adb("kill-server") print "Get Video file..." path = PATH("%s/video" %os.getcwd()) if not os.path.isdir(path): os.makedirs(path) utils.adb("pull /data/local/tmp/video.mp4 %s" % PATH("%s/%s.mp4" % (path, utils.timestamp()))).wait()
def top(): cpu = [] mem = [] top_info = utils.shell("top | %s %s$" %( utils.find_util, pkg_name)).stdout.readlines() print top_info input_key = raw_input("Please press the Enter key to stop :\n") if input_key == "": utils.adb("kill-server") print "Get top data..." for info in top_info: #temp_list = del_space(info) temp_list = info.split() cpu.append(temp_list[2]) mem.append(temp_list[6]) return (cpu, mem)
def top(): cpu = [] mem = [] top_info = utils.shell("top | %s %s$" % (utils.find_util, pkg_name)).stdout.readlines() print top_info input_key = raw_input("Please press the Enter key to stop :\n") if input_key == "": utils.adb("kill-server") print "Get top data..." for info in top_info: #temp_list = del_space(info) temp_list = info.split() cpu.append(temp_list[2]) mem.append(temp_list[6]) return (cpu, mem)
def data(req): param = req.GET.get("p1") if param == "start": try: mem_data = utils.adb( "-s 127.0.0.1:62001 shell dumpsys meminfo com.longtu.weifuhua|gawk '/MEMINFO/,/App Summary/'|grep TOTAL|gawk '{print $2}'").stdout.readline() except IOError: mem_data = 0 return HttpResponse(mem_data) else: return HttpResponse(0)
def get_match_apk(package_name): list = [] for packages in utils.shell("pm list packages -f %s" % package_name).stdout.readlines(): print packages.split(":")[-1].split("=")[0] list.append(packages.split(":")[-1].split("=")[0]) apk_name = list[0].split("/")[-1] print tempFile, apk_name print u"---上传App到本地temp目录----" if apk_name not in os.listdir(tempFile): utils.adb("pull %s %s" % (list[0], tempFile)).wait() print u"---上传App结束---" else: print u"---本地app已存在,不需要上传---" # return PATH("%s/%s" % (tempFile, apk_name))
def backup_app(): apps = get_apk_list() for apk in apps: utils.adb("pull %s backup_app" %apk).wait() print "pull %s succeed." %apk
try: _limit_time = int(limit_time) + 1 except: record() if 0 < _limit_time <= 180: utils.shell("screenrecord --time-limit %s /data/local/tmp/video.mp4" % limit_time).wait() else: print "Please set again!" record() if __name__ == "__main__": sdk = string.atoi( utils.shell("getprop ro.build.version.sdk").stdout.read()) if sdk < 19: print "sdk version is %s, less than 19!" sys.exit(0) else: record() print "Get Video file..." time.sleep(3) path = PATH("%s/video" % os.getcwd()) if not os.path.isdir(path): os.makedirs(path) utils.adb("pull /data/local/tmp/video.mp4 %s" % PATH("%s/%s.mp4" % (path, utils.timestamp()))) print "Completed"
def install(apkPath): print(utils.adb("install -r %s" % apkPath).stdout.read())
def install(apkPath): print (utils.adb("install -r %s" %apkPath).stdout.read())
PATH = lambda p: os.path.abspath(p) def get_match_apk(package_name, path): list = [] <<<<<<< HEAD <<<<<<< HEAD for packages in utils.shell("pm list packages -f %s" % package_name).stdout.readlines(): list.append(packages.split(":")[-1].split("=")[0]) ======= for packages in utils.shell("pm list packages -f %s" %package_name).stdout.readlines(): if packages.split(":")[0] == "package": list.append(packages.split(":")[-1].split("=")[0]) >>>>>>> upstream/master utils.adb("pull %s %s" % (list[0], path)).wait() ======= for packages in utils.shell("pm list packages -f %s" %package_name).stdout.readlines(): if packages.split(":")[0] == "package": list.append(packages.split(":")[-1].split("=")[0]) >>>>>>> upstream/master if __name__ == "__main__": path = PATH("%s/App" % os.getcwd()) if not os.path.isdir(path): os.makedirs(path) get_match_apk(utils.get_current_package_name(), path) print "Completed"
def record(): <<<<<<< HEAD <<<<<<< HEAD utils.shell("screenrecord /data/local/tmp/video.mp4") input_key = raw_input("Please press the Enter key to stop recording:\n") ======= utils.shell("screenrecord /data/local/tmp/video.mp4") input_key = raw_input("Please press the Enter key to stop recording:\n") >>>>>>> upstream/master ======= utils.shell("screenrecord /data/local/tmp/video.mp4") input_key = raw_input("Please press the Enter key to stop recording:\n") >>>>>>> upstream/master if input_key == "": utils.adb("kill-server") print "Get Video file..." <<<<<<< HEAD <<<<<<< HEAD path = PATH("%s/video" % os.getcwd()) ======= ======= >>>>>>> upstream/master utils.adb("start-server") time.sleep(1.5) path = PATH("%s/video" %os.getcwd()) >>>>>>> upstream/master if not os.path.isdir(path):
def backup_app(): apps = get_apk_list() for apk in apps: utils.adb("pull %s backup_app" % apk).wait() print "pull %s succeed." % apk