【Python】设备重启测试
2024-08-28 05:56:35
①添加读取键盘输入功能,方便测试者选择压测次数!
Python提供了 input() 内置函数从标准输入读入一行文本,默认的标准输入是键盘。
input 可以接收一个Python表达式作为输入,并将运算结果返回。
例:
#!/usr/bin/python3
str = input("请输入:");
print ("你输入的内容是: ", str)
这会产生如下对应的结果:
请输入:ABCD
你输入的内容是: ABCD
#!/usr/bin/python
# -*- coding: UTF-8 -*-
'''
==============================================================================================
Usage:
This script performs task that pressure test for automatic restart of equipment.
python RebootTest.py
Examples:
python RebootTest.py
==============================================================================================
'''
import os
import time
rebootCount = int(input("请输入重启次数:"));
print ("你输入的次数是: ", rebootCount)
def find_device():
# os.system('adb kill-server')
# os.system('adb start-server')
# os.system('adb root')
# os.system('adb remount')
print("adb devices")
os.system('adb devices')
def reboot():
os.system('adb reboot')
def screen_downup():
os.system('adb shell input keyevent 26')
def power_downup():
os.system('adb shell sendevent /dev/input/event0 1 116 1')
os.system('adb shell sendevent /dev/input/event0 0 0 0')
os.system('adb shell sendevent /dev/input/event0 1 116 0')
os.system('adb shell sendevent /dev/input/event0 0 0 0')
def get_log(name,count):
os.system('adb logcat -t 50000 > '+name+count+'.log')
#重启
for i in range(0,rebootCount):
find_device
screen_downup()
print("screen_down")
time.sleep(5)
screen_downup()
print("screen_up")
time.sleep(5)
print("power_down")
power_downup()
time.sleep(5)
print("power_up")
power_downup()
count=str(i)
get_log(name="reboot",count=count)
print("auto_reboot loop again")
reboot()
print("wait auto_reboot 60s")
time.sleep(60)
print("auto_reboot finish\n")
最新文章
- [转]中国最大的Webshell后门箱子调查,所有公开大马全军覆没
- 微信录音接口的调用以及amr文件转码MP3文件的实现
- 一张图说明CDN网络的原理
- 【Python①】python简介,安装以及配置
- c# 高效率导出多维表头excel
- bootstrap和jquery mobile的对比
- [转载]SAP BASIS学习手册
- Android之BroadcastReceiver 监听系统广播
- 17+个ASP.NET MVC扩展点,含源码{转}
- Flex设置外部浏览器
- 使用enable_shared_from_this示例
- ExtJS 创建动态加载树
- 基于visual Studio2013解决C语言竞赛题之0513字符拷贝
- B/S与C/S架构
- ASP.NET与ASP.NET Core用户验证Cookie并存解决方案
- 10 分钟速成 Python3
- HDU1166-敌兵布阵 (线段树)
- 企业项目构建学习(一)maven
- JS前端创建CSV或Excel文件并浏览器导出下载
- Filberder教程
热门文章
- [Angular Directive] Create a Template Storage Service in Angular 2
- 小强的HTML5移动开发之路(33)—— jqMobi基础
- 【codeforces 768A】Oath of the Night's Watch
- 【Material Design视觉设计语言】开篇
- T-SQL部分函数(转)
- 推荐一款软件mybatis-generator-gui
- 在线算法交互、可视化与演示及应用(caffe 网络配置文件 .prototxt 的可视化)
- java读取Properties文件及赋值
- java写文件时往末尾追加文件(而不是覆盖原文件),的两种方法总结
- cocos2d-x 调色