#!/usr/bin/env python
os.system(“gnome-terminal -e ‘bash -c “ls; exec bash”’”)
-- coding: utf-8 --
import linecache
#import pyautogui
import os
import re
import shutil
import time
import smtplib
import time
import random
from email.mime.application import MIMEApplication
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
from email.mime.multipart import MIMEMultipart
mail_from = ‘shixinfa@baidu.com’
receiver = [mail_from,‘shixinfa@baidu.com’]
receiver = [mail_from]
mail_subject = ‘linux monkey test result’
##第0步下载对应的模块类库
def installdemo():
#cmd=(‘curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py’)
#os.system(cmd)
#time.sleep(100)
#cmdnext=(‘python get-pip.py’)
#os.system(cmdnext)
#time.sleep(10)
cmdpygui=(‘pip install pyautogui’)
os.system(cmdpygui)
##第1步拉取最新的代码
def gitpullcode():
##切换到你的项目目录,并执行代码拉取脚本
os.system(‘cd /home/sxf’)
os.system(‘cd /home/sxf/zhuxin/baidu/iov/sz/mapauto-interface’)
pullcode()
def pullcodedev():
os.system(‘git stash’)
os.system(‘git checkout dev’)
os.system(‘git pull’)
os.system(‘sleep 35s’)
def pullcode():
os.system(‘git stash’)
os.system(‘git checkout sdk-dev’)
os.system(‘git pull’)
os.system(‘sleep 35s’)
##第2步执行monkey脚本
def clickmonkey():
screenWidth, screenHeight=pyautogui.size()
print(“width========”)
print(screenWidth)
print(“Height========”)
print(screenHeight)
currentMouseX, currentMouseY=pyautogui.position()
print(“cureent poisttioncurrentMouseX======”)
print(currentMouseX)
print(“cureent poisttioncurrentMouseY======”)
print(currentMouseY)
for i in range(1, 10000):
pyautogui.moveTo(random.randint(120, screenWidth - 10), random.randint(0, screenHeight), 0)
pyautogui.click();
if (i % 500):
pyautogui.moveTo(98, 66, 0)
pyautogui.click();
if (i % 1000):
pyautogui.moveTo(524, 161, 0)
pyautogui.click();
pyautogui.moveTo(800, 199, 1)
pyautogui.rightClick()
time.sleep(1)
pyautogui.moveTo(800, 354, 1)
pyautogui.click();
time.sleep(4)
pyautogui.moveTo(148, 722, 1)
pyautogui.click();
#第3步定时执行脚本
def timer(n):
‘’’’’
每n秒执行一次
‘’’
while True:
print(time.strftime(’%Y-%m-%d %X’,time.localtime()))
# 此处为要执行的任务
str = (‘python /Users/shixinfa/Documents/mapautomation/src/util/sendmail.py’)
os.system(str)
time.sleep(n)
##第4步计算是否有新的crash文件产生
def dircount(DIR):
print len(os.listdir(DIR))
return len(os.listdir(DIR))
##第5步生成测试报告
def testResult():
msg = MIMEMultipart(‘mixed’)
msg[‘Subject’] = mail_subject
msg[‘From’] = mail_from
msg[‘To’] = “;”.join(receiver)
html_text = ‘’’
| 开始测试时间 | 20200612 |
| 结束测试时间 | 20200613 |
| crash发生时间 | 20200614 |
| crash个数 | 20 |
| crash log | log link |
1056

被折叠的 条评论
为什么被折叠?



