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 ...
随机推荐
- C语言一些常用内存分配函数
首先看个问题程序(这里用的是TC编译器): #include "stdlib.h" #include "stdio.h" void main() { in ...
- cojs 疯狂的字符串 题解报告
首先这道题是GT考试的加强版本QAQ 当n<k的时候,答案显然是10^n 当n=k的时候,答案显然是10^n-1 这样就有20分辣 之后我们考虑k<=20的做法 显然设f(i,j)表示前i ...
- threadlocal精髓是为每一个线程保证一个共享对象,保证一个,保证是同一个
threadlocal精髓是为每一个线程保证一个共享对象,保证一个,保证同一个线程中是同一个共享对象. 如果是静态变量是共享的话,那必须同步,否则尽管有副本,还是会出错,故C错
- Mysql笔记——触发器简单实例
首先贴上触发器语法吧: CREATE TRIGGER <触发器名称> –触发器必须有名字,最多64个字符,可能后面会附有分隔符.它和MySQL中其他对象的命名方式基本相象. { BEFOR ...
- 改变dijit的长度的心得
改变dijit的长度要进入到里面改 如dijit/form/Select (以table的方式来组合控件) 改变的时候,先找到dijitButtonContent 然后在后面样式文件里写就可以了 ...
- [cocoapods]安装cocoapods
如果你的电脑已经安装过cocoapods了,但是不知道怎么用,请直接跳转到第8步 在安装之前,我们先来了解什么是cocoapods 当你开发iOS应用时,会经常使用到很多第三方开源类库,比如JSONK ...
- FastDFS之java客户端使用
为了方便应用程序的访问FastDFS,官网提供了fastdfs-client-java,以便更好的与应用程序结合使用. 下载fastdfs-client-java源码添加到项目工程里面,添加配置文件: ...
- Bootstrap学习笔记之整体架构
之前有粗略地看过一下Bootstrap的内容,不过那只是走马观花式地看下是怎么用的,以及里面有什么控件,所以就没想着记笔记.现在由于要给部门做分享,所以不得不深入地去学习下,不然仅是简单地说下怎么用, ...
- Oracle ->> Oracle下生成序列的方法
用hierachical query,即connect by配合dual表生成序列,mod这个是取余函数,生成group factor.最后面的connect by rownum <= 100可 ...
- spring springmvc mybatis 整合
环境 apache-tomcat-8.0.33.jdk1.8.0_05 maven Dynamic Web Module 2.5 1.各个xml配置文件的配置 (1)pom.xml 配置清单文件 连接 ...