91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

monkey命令性能測試

發布時間:2020-06-13 13:04:05 來源:網絡 閱讀:398 作者:知止內明 欄目:編程語言

new一下調試成功,可以直接使用

import time, os, random
import subprocess
import re

PATH = lambda p: os.path.abspath(os.path.join(os.path.dirname(__file__), p))

#注意apk包的存放路徑

class adbmokeybast(object):
     filename = ""
    packagename = ""
    versionCode = ""
    versionName = ""

    def __init__(self, adbdeves, locatpath):
        self.adbdeves = adbdeves
        self.locatpath = locatpath
        self.clsriz()

    def getApkBaseInfo(self):
        getcmd = 'aapt d badging  %s  |findstr "package launchable-activity"' % self.locatpath
        result = subprocess.Popen(getcmd, stdout=subprocess.PIPE,
                                  stderr=subprocess.PIPE,
                                  stdin=subprocess.PIPE, shell=True)
        (output, err) = result.communicate()
        match = re.compile("package: name='(\S+)' versionCode='(\d+)' versionName='(\S+)'").match(output.decode())
        if not match:
            raise Exception("can't get packageinfo")
        self.packagename = match.group(1)
        self.versionCode = match.group(2)
        self.versionName = match.group(3)

        print('packagename:' + self.packagename)
        print('versionCode:' + self.versionCode)
        print('versionName:' + self.versionName)
        return self.packagename, self.versionName, self.versionCode

    def clsriz(self):
        os.system("cls")  # 清楚日志
        print("adb 啟動中...")
        # 鏈接模擬器 進行測試
        os.popen("adb connect 127.0.0.1:62001")
        os.popen("adb devices")  # 執行命令
        os.system("cls")

    def adbmokdeyaut(self):
        result = os.popen(self.adbdeves).readlines()  # os.popen()執行系統命令并返回執行后的信息對象
        devices = []
        devicesdec = {}
        # 保存選擇設備號
        dev = ""
        alen = len(result)
        new_a = result[1:alen - 1]
        for i in range(len(new_a)):
            newadvices = new_a[i].split("\t")
            if newadvices[1] == "device\n":
                devices.append(newadvices[0])
                devicesdec[i] = newadvices[0]
            else:
                return "沒有可以用的設備號"
        print(devices)
        print(devicesdec)
        try:
            while True:
                nSel = int(input("選擇輸入設備按序號就行: "))
                for k, v in devicesdec.items():
                    if nSel == k:
                        print("您輸入的序號為:%d,設備號為: %s" % (int(nSel), devicesdec[nSel]))
                        dev = devicesdec[nSel]
                        break
                else:
                    print("你輸入的有誤!!!")
                    continue
                break
        except:
            print("輸入有誤,程序停止")
            return 0

        self.filename = input("輸入保存的結果文件名:")
        fd = open(self.filename + '.cmd', 'w')
        monkeypath = "e:\\monkey\\" + self.filename
        if not os.path.isfile(monkeypath):
            os.mkdir(monkeypath)
        print(monkeypath)
        fd.write(":loop\n")
        fd.write("adb -s ")  # 選擇設備
        fd.write(dev)  # 設備號
        # -s %random%的意思是防止產品相同的時間避免重復執行同一種動作  320000
        cmmmdgetapck = " shell monkey  -p ${packes} --monitor-native-crashes  --pct-touch 80 --pct-motion 15 --pct-nav 5 -s %random% -v  --throttle 500 320000".replace(
            "${packes}", self.packagename)
        fd.write(cmmmdgetapck + "  >" + monkeypath)
        fd.write("\\%random%.log\n")
        # ping自己15次用來延遲
        fd.write("@ping -n 15 127.1 >nul\n")
        fd.write("adb -s ")
        fd.write(dev)
        fd.write(" reboot\n")
        fd.write("@ping -n 120 127.1 >nul\n")
        fd.write("@goto loop")
        fd.close()
        print("批處理生成完畢")

    def cmdrun(self):
        path = os.getcwd()
        print(path)
        self.adbmokdeyaut()
        print("============" + self.filename)
        os.system(self.filename)

if __name__ == '__main__':
    locatpath = PATH(r'apk\XXXX.apk')
    am = adbmokeybast("adb devices", locatpath)
        #獲取包名
    am.getApkBaseInfo()
        #啟動全部程序
    # am.cmdrun()

old

#! /usr/bin/env python
# -*- coding:utf-8 -*-
# Author: liwen
'''
@time: 2018/8/6 9:19
'''
import os
import os.path

def clsriz():
    os.system("cls")  # 清楚日志
    print "adb 啟動中..."
    os.popen("adb devices")  # 執行命令
    os.system("cls")

def operation():
    result = os.popen('adb devices').readlines()  # os.popen()執行系統命令并返回執行后的信息對象
    n = len(result) - 2
    print result
    print "檢測到" + str(n) + "臺設備:"
    devices = range(n)
    for i in range(n):
        nPos = result[i + 1].index("\t")
        devices[i] = result[i + 1][:nPos]
        print str(i + 1) + " - " + devices[i]
    print " "
    nSel = 1
    if n != 1:
        nSel = input("選擇設備:")
    if nSel <= n:
        dev = devices[nSel - 1]

    fn = raw_input("輸入文件名:")
    fd = open(fn + '.cmd', 'w')

    if not os.path.isdir("D:\\" + fn):
        os.mkdir("D:\\" + fn)

    fd.write(":loop\n")
    fd.write("adb -s ")  # 選擇設備
    fd.write(dev)  # 設備號
    fd.write(
        " shell monkey  -p com.android.browser --monitor-native-crashes  --pct-touch 80 --pct-motion 15 --pct-nav 5 -s %random% -v  --throttle 500 320000 >d:\\")  # -s %random%的意思是防止產品相同的時間避免重復執行同一種動作
    fd.write(fn)
    fd.write("\\%random%.log\n")
    fd.write("@ping -n 15 127.1 >nul\n")  # ping自己15次用來延遲
    fd.write("adb -s ")
    fd.write(dev)
    fd.write(" reboot\n")
    fd.write("@ping -n 120 127.1 >nul\n")
    fd.write("@goto loop")

    fd.close()

    print "批處理生成完畢"

if __name__ == '__main__':
    # clsriz()
    operation()

修改版本

result = os.popen(self.adbdeves).readlines()  # os.popen()執行系統命令并返回執行后的信息對象
        devices = []
        devicesdec = {}
        # 保存選擇設備號
        dev = ""
        alen = len(result)
        new_a = result[1:alen - 1]
        for i in range(len(new_a)):
            newadvices = new_a[i].split("\t")
            if newadvices[1] == "device\n":
                devices.append(newadvices[0])
                devicesdec[i] = newadvices[0]
            else:
                return "沒有可以用的設備號"
        print(devices)
        print(devicesdec)
        try:
            while True:
                nSel = int(input("選擇輸入設備按序號就行: "))
                for k, v in devicesdec.items():
                    if nSel == k:
                        print("您輸入的序號為:%d,設備號為: %s" % (int(nSel), devicesdec[nSel]))
                        dev = devicesdec[nSel]
                        break
                else:
                    print("你輸入的有誤!!!")
                    continue
                break
        except:
            print("輸入有誤,程序停止")
            return 0

#第二種方法:
 devices = []
    import subprocess
    result = subprocess.Popen("adb devices", shell=True, stdout=subprocess.PIPE,
                              stderr=subprocess.PIPE).stdout.readlines()
    for item in result:
        t = item.decode().split("\tdevice")
        if len(t) >= 2:
            devices.append(t[0])
    return devices
向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

郸城县| 常山县| 颍上县| 永和县| 饶平县| 山东| 磐石市| 郁南县| 修文县| 丹棱县| 眉山市| 长乐市| 柘荣县| 清徐县| 鹤庆县| 开平市| 拜泉县| 阳原县| 柳江县| 交口县| 江津市| 江山市| 资中县| 东明县| 融水| 金坛市| 于田县| 龙游县| 谢通门县| 额尔古纳市| 古丈县| 武定县| 盈江县| 武功县| 彩票| 邢台市| 文登市| 东平县| 福州市| 胶南市| 承德县|