设为首页 加入收藏

TOP

wxPython制作跑monkey工具(Python3)(一)
2019-09-14 00:50:57 】 浏览:227
Tags:wxPython 制作 monkey 工具 Python3

#!/usr/bin/env python


import wx
import os
import sys
import time


from threading import Thread



#执行adb命令函数
#使用到的线程:RunMonkeyThread(),KillMonkeyThread(),ExportLogThread()
def excuOrder(orderName):
    c = os.system(orderName)
    print(c)
    return c


#将指定内容写入指定文件(写入monkey日志报错信息)
#使用到的函数:findException()
def writeFile(FileName, content):
    FName = open(FileName, 'a')
    FName.write(content)
    FName.close()


#查找指定文件里指定字符串的个数,并输出字符串所在行的内容
#使用到的线程:ExportLogThread()
def findException(tfile,sstr):
    try:
        lines=open(tfile,'r').readlines()
        flen=len(lines)-1
        acount = 0
        fileException = "%s_%s" % (tfile,sstr)
        tfileException = "%s.txt" % fileException
       
        writeFile(tfileException,"%s keywords:\n" % fileException)
        for i in range(flen):
            if sstr in lines[i]:
                lineException = '\t%s\n'% lines[i]


                writeFile(tfileException,lineException)
                acount+= 1


        writeFile(tfileException,"%s  frequency:%s" % (fileException,acount))
        print('Please check Exception keywords in the "%s"\n' % tfileException)
    except Exception as e:
        print(e)


 


class RunMonkeyThread(Thread):



    def __init__(self):
        #线程实例化是立即启动
        Thread.__init__(self)
        self.logNameST = logNameST
        self.start()
       
    def run(self):
        print("Start running monkey ...\n")
        self.packageName=packageText.GetValue()
        self.MonkeyTime=MTText.GetValue()
        self.MonkeyCount=MCText.GetValue()
        self.strTime = time.strftime('%Y%m%d%H%M%S',time.localtime(time.time()))
        self.logName = '%s_%s_monkey.log'%(self.packageName,self.strTime)
        open(r"logname.txt",'w').write(self.logName)
        self.logNameST.SetLabel("%s" % self.logName)
       
        self.orderName1='adb shell "monkey -p %s --throttle %s --ignore-crashes --monitor-native-crashes \
                            --ignore-security-exceptions --ignore-timeouts --ignore-native-crashes --pct-syskeys\
                            0 --pct-nav 20 --pct-majornav 20 --pct-touch 40 --pct-appswitch 10 -v -v -v %s\
                            > /sdcard/%s&" '% (self.packageName,self.MonkeyTime,self.MonkeyCount,self.logName)
      &nb

首页 上一页 1 2 3 4 5 下一页 尾页 1/5/5
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Python PIL库图像处理操作详解 下一篇Python3使用PySynth制作音乐

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目