monkey+python2.7,暂时不完善

公司正在开发一款app,本着练手的原则,不放过每一次练习的机会。monkey+python2.7,简单的写了一下,基本可以,后续日志方面的东西还没整好。

#_*_coding=utf-8 _*_
#__author__ = 'Administrator'


import os
import smtplib
from email.mime.text import MIMEText
from email.header import Header
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email import Encoders
import subprocess
import re

def emaile(i):
    #构造纯文本邮件内容
    body = MIMEText('新近我寂寞浓烈如酒,夕阳下多姿的垂柳,亦让人不知其是长袖善舞还是骚在其骨...','plain','utf-8')
    msg =MIMEMultipart()
    #发件人邮箱地址
    sender = '809647468@qq.com'
    user = '809647468'
    password = 'zlmjeoeivdqfbecj'
    #smtp服务器地址
    smtpserver = 'smtp.qq.com'
    #接收者邮箱地址
    receiver = "809647468@qq.com"
    msg['from']=sender
    msg['to']=receiver
    subject = 'chubby superman salutes you'
    msg['subject']=Header(subject,'utf-8')
    part =MIMEBase('application','octet-stream')
    txt = r'c:\test%d.txt'%i
    part.set_payload(open(txt,'rb').read())
    Encoders.encode_base64(part)
    part.add_header('Content-Disposition', 'attachment; filename="test%d.txt"'%i)
    msg.attach(part)
    smtp = smtplib.SMTP()
    smtp.connect(smtpserver,25)
    smtp.login(user,password)
    smtp.sendmail(sender,receiver,msg.as_string())
    smtp.quit()
    open(txt,'rb').close()
    print('ahahah')

os.system('adb kill-server')
os.system('taskkill /IM cmd.exe /F')
for i in range(20):
    a = 'taskkill /IM adb.exe /F&adb logcat *:e > c:\\test%d.txt&adb shell monkey -p com.health3722.pipicalculator --pct-touch 45 --pct-motion 45 ' \
             '--pct-trackball 0 --pct-appswitch 10 --pct-anyevent 0 --pct-nav 0 --pct-majornav 0 --pct-syskeys 0 -s 2 -v-v-v  100&taskkill /IM cmd.exe /F'%i
    monkey = 'adb shell monkey -s %s -p com.health3722.pipicalculator  --pct-touch 35' \
             ' --pct-syskeys 30 --pct-appswitch 35 --hprof --throttle 100 -v -v -v 10000 logcat *:e > c:\\test%s.txt'%(i,i)
    os.system(monkey)
    fp = file("c:\\test%i.txt"%i,'r')
    #count = 0
    print(i)
    for s in fp.readlines():
        li = re.findall('CrashManager',s)
        li1= re.findall('crash',s)
        if len(li)>0 or len(li1)>0:
            emaile(i)
    fp.close()
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值