adb shell 查找并删除文件
# -*- coding: cp936 -*-
## function: remove file
## remark: python version -- import os,sys
import logging,re
import time, datetime PART = "file"
LOG_PATH = "./rmfile.log"
##global del_number=
del_number = ## 写日志
logger = logging.getLogger()
formatter =logging.Formatter ("%(asctime)s - %(levelname)s - %(message)s")
file_handler = logging.FileHandler(LOG_PATH)
file_handler.setFormatter(formatter)
stream_handler = logging.StreamHandler(sys.stderr)
logger.addHandler(file_handler)
logger.addHandler(stream_handler)
logger.setLevel(logging.DEBUG) def rmfile():
try:
res_rm =
os.system("adb shell ls /mnt/sdcard > ./filename.txt") ## print "find file and remove" fd = open("./filename.txt")
##如果文件中没有内容,连接失败,退出
if os.stat ("./filename.txt").st_size ==:
res_rm = -
## print "connect devices failed, in rm ()"
logger.debug("connect devices failed")
return res_rm
for eachline in fd:
## print "each line",eachline
if re.search(PART,eachline):
## print "file is here"
global del_number
del_number = del_number +
os.system("adb shell rm /mnt/sdcard/file")
## print "delete file"
logger.debug("file id here,delete file")
##
logger.debug("start iperf explorer")
os.system ("E:/jperf-2.0.0/jperf-2.0.0/bin/iperf.exe -c ***.***.***.*** -u -i 1 -t 20 -b 800K -l 500 > D:/Pyehon2_7_3/iperf.log")
fd_iperf = open("./iperf.log")
for eachline_iperf in fd_iperf:
print eachline_iperf
logger.debug(eachline_iperf)
logger.debug("end iperf explorer")
return res_rm
except Exception,e:
print str(e)
res_rm = -
logger.error("[Exception]"+str(e))
return res_rm
def main():
global del_number
## AVG_bw =
TOL_bw =
try:
logger.debug("============start==============")
for i in range(,):
## 60s 检查一次文件,检查1000次
logger.debug("nu "+str(i)+" start")
res = rmfile()
if res == -:
## print "connect devices failed" ,res
logger.error("connect devices failed") logger.debug("=============end================")
return res
time.sleep()
## print i,"find 1000"
logger.debug("nu "+str(i)+" end")
logger.debug("********iperf explorer"+str(del_number)+"********")
logger.debug("***********iperf explorer"+"res"+"***************")
fd_iperf = open("./iperf.log")
for eachline in fd_iperf:
## print eachline
par1 = re.search ("0.0-",eachline)
par2 = re.search ("%",eachline)
if par1 and par2:
logger.debug(eachline)
TOL_bw = TOL_bw + int(eachline.split(" ")[])
## print "TOL_bw",TOL_bw
## print "del_number" ,del_number
AVG_bw = float(TOL_bw)/float(del_number)
## print "AVG_bw",AVG_bw
logger.debug("*******iperf explorer AVG "+str(AVG_bw)+"********")
logger.debug("********del file "+str(del_number)+"********")
logger.debug("=============end===============") return
except Exception,e:
print str(e)
logger.error("[Exception]"+str(e))
res = -
return res
if __name__ == "__main__":
main()
adb shell 查找并删除文件的更多相关文章
- 使用adb shell 进入手机修改文件的权限
1.将android的tools目录加入到path中,或者直接在adb.exe路径下启动cmd窗口2.adb shell 进入手机后,发现是 $ ,不是 # 号3.在进入shell后运行 su ,就可 ...
- linux中find与rm实现查找并删除文件
find命令: find . -name '*.log' #查找当前目录下的log文件 查找并删除: find . -name '*.log' -type f -print -exec rm -rf ...
- Python批量查找和删除文件操作
查找文件夹下的所有子文件 import os allfile=[] def dirlist(path): filelist=os.listdir(path) #fpath=os.getcwd() fo ...
- Linux 下查找并删除文件命令
以查找和删除mp3为扩展的文件为例: find . -name "*.mp3" |xargs rm -rf (.表示在当前目录下执行)
- Linux find 查找 并删除文件 杀掉进程
find 默认在当前 即 . 目录下查找 du 文件名 / 目录 # 查看文件占用内存大小 1. 按照文件名查找 find / -name qwe # qwe为文件名 find / -name *qw ...
- linux 查找 并删除 文件
find / -name "*.mp3" |xargs rm -rf会删除所有以mp3为扩展的文件.操作的时候先: find / -name "*.mp3" 会 ...
- shell下如何删除文件的某一列
答:cat file | awk '{$1=null;print $0}' (删除第一列)
- [ADB Shell]Android Debug Bridge常用命令
ADB用法 *:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 !important ...
- Linux命令行批量删除文件(目录)
快速-批量删除文件或目录 1-1.快速删除大文件夹(注意目录后的结束符'/')(对于含有海量文件的目录,不能直接rm -rf删除,这样效率很慢:) rsync -a --delete blank/ t ...
随机推荐
- Codeforces Round #336 (Div. 2)C. Chain Reaction DP
C. Chain Reaction There are n beacons located at distinct positions on a number line. The i-th bea ...
- JavaScript. The core.
Read this article in: Japanese, German (version 2), Arabic, Russian, French, Chinese. An object A pr ...
- linq lambda 分组后排序
1.lamdba分组排序foodBusinessDistrict. GroupBy(x => new ...
- Android Non-UI to UI Thread Communications(Part 1 of 5)
original:http://www.intertech.com/Blog/android-non-ui-to-ui-thread-communications-part-1-of-5/ ANDRO ...
- 唉,还是Windows好
作为一个计算机专业的,常常抱怨Windows慢.一个系统用一段时间慢下来就重装,但是次次重装很麻烦,每次重装之后还得装软件. 另外,Windows比Linux占资源,所以前段时间就想以Linux为主要 ...
- interviewbit : Max Non Negative SubArrayBookmark Suggest Edit
Find out the maximum sub-array of non negative numbers from an array.The sub-array should be continu ...
- http://www.360doc.com/content/12/1014/00/7471983_241330790.shtml
http://www.360doc.com/content/12/1014/00/7471983_241330790.shtml
- Java:静态导入
静态导入 importStatic 当类重名时,需要指定具体的包名. 当方法重名时,需要指定具体的类或对象名. 举例如下: import java.util.*; import static java ...
- struts2与struts1整合,Unable to load configuration. - interceptor-ref ... struts.xml
struts.xml中为了与struts1的MVC模式整合,需要类似如下的拦截器的引用 <interceptor-stack name="integration"> & ...
- AbsListView.OnScrollListener 使用注意事项
这个类没什么特别的,但是使用的时候我确出错了 abstract void onScroll(AbsListView view, int firstVisibleItem, int visibleIte ...