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 ...
随机推荐
- Useful for Android the development engineer from Github
Original:http://sysmagazine.com/posts/216591/ Many plowing on open space Github, I found assemblage ...
- 【转】VC++与MySQL数据库的连接
原文地址:http://blog.csdn.net/nupt123456789/article/details/8043091 1.MySQL数据库的安装 你可以从MySQL的官网上或者从如下地址下载 ...
- win7 64 + Ubuntu 14.04.1 64双系统安装,详解UEFI ~ GPT和legacy ~ MBR区别
win7 64 + Ubuntu 14.04.1 64双系统安装 背景:我的笔记本之前的系统是window 7 64 + Ubuntu 14.04.1,用UEFI引导系统.安装过程是先装的win7,再 ...
- 浅谈Spark Kryo serialization
原创文章,转载请注明: 转载自http://www.cnblogs.com/tovin/p/3833985.html 最近在使用spark开发过程中发现当数据量很大时,如果cache数据将消耗很多的内 ...
- Unsupported major.minor version 51.0(jdk版本错误)
解决方案: 步骤一: 在“项目”点右键->选择Perperties->在出现的菜单中选择Java Compiler->最上面选中Enable project Specific set ...
- Linux 与 CONE NAT 和 Symmetric NAT
http://alexanderlaw.blog.hexun.com/31883661_d.html 1. NAT 的划分 RFC3489 中将 NAT 的实现分为四大类: 1. Full Cone ...
- iOS开发多线程--技术方案
pthread 实现多线程操作 代码实现: void * run(void *param) { for (NSInteger i = 0; i < 1000; i++) { ...
- iOS开发--邮箱,电话号码,身份证正则表达式验证
//邮箱 + (BOOL) validateEmail:(NSString *)email { NSString *emailRegex = @"[A-Z0-9a-z._%+-]+@ ...
- iOS开发--沙盒路径与操作文件
获取应用沙盒根路径: -(void)dirHome{ NSString *dirHome=NSHomeDirectory(); NSLog(@"app_home: %@",dirH ...
- mysql 常用命令(备忘)
1:使用SHOW语句找出在服务器上当前存在什么数据库: mysql> SHOW DATABASES; 2:2.创建一个数据库MYSQLDATA mysql> CREATE DATABASE ...