# -*- 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 查找并删除文件的更多相关文章

  1. 使用adb shell 进入手机修改文件的权限

    1.将android的tools目录加入到path中,或者直接在adb.exe路径下启动cmd窗口2.adb shell 进入手机后,发现是 $ ,不是 # 号3.在进入shell后运行 su ,就可 ...

  2. linux中find与rm实现查找并删除文件

    find命令: find . -name '*.log' #查找当前目录下的log文件 查找并删除: find . -name '*.log' -type f -print -exec rm -rf ...

  3. Python批量查找和删除文件操作

    查找文件夹下的所有子文件 import os allfile=[] def dirlist(path): filelist=os.listdir(path) #fpath=os.getcwd() fo ...

  4. Linux 下查找并删除文件命令

    以查找和删除mp3为扩展的文件为例: find . -name "*.mp3" |xargs rm -rf   (.表示在当前目录下执行)

  5. Linux find 查找 并删除文件 杀掉进程

    find 默认在当前 即 . 目录下查找 du 文件名 / 目录 # 查看文件占用内存大小 1. 按照文件名查找 find / -name qwe # qwe为文件名 find / -name *qw ...

  6. linux 查找 并删除 文件

    find / -name "*.mp3" |xargs rm -rf会删除所有以mp3为扩展的文件.操作的时候先: find / -name "*.mp3" 会 ...

  7. shell下如何删除文件的某一列

    答:cat file | awk '{$1=null;print $0}' (删除第一列)

  8. [ADB Shell]Android Debug Bridge常用命令

    ADB用法 *:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 !important ...

  9. Linux命令行批量删除文件(目录)

    快速-批量删除文件或目录 1-1.快速删除大文件夹(注意目录后的结束符'/')(对于含有海量文件的目录,不能直接rm -rf删除,这样效率很慢:) rsync -a --delete blank/ t ...

随机推荐

  1. JavaScript. The core.

    Read this article in: Japanese, German (version 2), Arabic, Russian, French, Chinese. An object A pr ...

  2. MyEclipse — Maven+Spring+Struts+Hibernate 整合 [学习笔记-4]

    引入Hibernate 在pom.xml中加入jar包引用 <!-- hibernate4 --> <dependency> <groupId>org.hibern ...

  3. intent传递参数

    来建第一个Activity:MyIntent  [mw_shl_code=java,true]public class MyIntent extends Activity {              ...

  4. java多线程知识点总结

    1.线程调度知识:线程类Thread的了解,几个thread的方法.thread.sleep(),thread.join().(调用join方法的那个线程会立刻执行). object.wait()方法 ...

  5. ubuntu下搭建cocos2dx编程环境-上

        这大半年一直在开发flash游戏,用到的编程语言是actionscript和c++.所以这次公司决定开发手游端的话,C++不是很生疏,这是个好消息.坏消息是由于现在网页游戏还没有上线,所以公司 ...

  6. UML系列03之UML时序图

    时序图介绍 时序图(Sequence Diagram),亦称为序列图或循序图,是一种UML行为图.时序图是用来描述系统内部是如何交互运作的,它通过描述对象之间发送消息的时间顺序显示多个对象之间的动态协 ...

  7. javascript中对象的属性的特性

    1.ES5的属性特性包括下面六个: configurable: 表示能否通过delete来删除属性从而重新定义属性,能够修改属性的特性,默认为true enumberable: 表示是否能通过for- ...

  8. nandflash学习1——导致nandflash反转的原因【转】

    转自:http://blog.csdn.net/gaosentao/article/details/7711311 Bit Flip/Bit Flipping/Bit-Flip/Bit twiddli ...

  9. ubuntu samba服务器多用户配置【转】

    转自:http://www.2cto.com/os/201204/127043.html ubuntu samba服务器多用户配置   在/home/下有多个用户目录A.B...,现通过samba共享 ...

  10. 验证码图片生成工具类——Captcha.java

    验证码图片生成工具,使用JAVA生成的图片验证码,调用getRandcode方法获取图片验证码,以流的方式传输到前端页面. 源码如下:(点击下载  Captcha.java) import java. ...