# -*- coding: cp936 -*-
## function: remove file
## remark: python version 2-7-3import os,sys
import logging,re
import time, datetimePART = "file"
LOG_PATH = "./rmfile.log"
##global del_number=0
del_number = 0##  写日志
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 = 0os.system("adb shell ls /mnt/sdcard > ./filename.txt")##        print "find file and remove"fd = open("./filename.txt")
##如果文件中没有内容,连接失败,退出if os.stat ("./filename.txt").st_size ==0:res_rm = -1
##            print "connect devices failed, in rm ()"logger.debug("connect devices failed")return res_rmfor eachline in fd:
##            print "each line",eachline    if re.search(PART,eachline):
##                print "file is here"global del_numberdel_number = del_number + 1os.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_iperflogger.debug(eachline_iperf)logger.debug("end iperf explorer")return res_rmexcept Exception,e:print str(e)res_rm = -1logger.error("[Exception]"+str(e))return res_rm
def main():global del_number
##    AVG_bw = 0TOL_bw = 0try:logger.debug("============start==============")for i in range(1,1000):
## 60s 检查一次文件,检查1000次logger.debug("nu "+str(i)+" start")res = rmfile()if res == -1:
##                print "connect devices failed" ,reslogger.error("connect devices failed")logger.debug("=============end================")return restime.sleep(60)
##            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 eachlinepar1 = re.search ("0.0-",eachline)par2 = re.search ("%",eachline)if par1 and par2:logger.debug(eachline)TOL_bw = TOL_bw + int(eachline.split(" ")[9])
##                print "TOL_bw",TOL_bw
##                print "del_number" ,del_numberAVG_bw = float(TOL_bw)/float(del_number)
##        print "AVG_bw",AVG_bwlogger.debug("*******iperf explorer AVG "+str(AVG_bw)+"********")logger.debug("********del file "+str(del_number)+"********")logger.debug("=============end===============")return 0except Exception,e:print str(e)logger.error("[Exception]"+str(e))res = -1return res
if __name__ == "__main__":main()

转载于:https://www.cnblogs.com/Pierre-de-Ronsard/p/3329821.html

adb shell 查找并删除文件相关推荐

  1. Shell查找并删除重复文件(仅留一份)

    删除文件中文件大小一样内容一致的文件,仅仅保留其中一个 #!/bin/bash # -lS 对当前目录下的所有文件按照文件大小进行排序并列出文件的详细信息 # --time-style=long-is ...

  2. shell 编程基础——删除文件而不删除文件夹

    最好的学习方法,莫过于从实践中学习. 首先需要区分文件和文件夹,需要使用 find 命令加 -type f 的参数,找出文件下下的所有文件.其次再通过rm -rf 的命令删除文件.我首先想到的是这样子 ...

  3. linux删文件进程叫什么,Linux find 查找 并删除文件 杀掉进程

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

  4. 安卓adb shell模式下创建文件夹出现Permission denied时的解决办法

    进入一个安卓模拟器的adb shell命令模式后使用如下方法创建文件夹 generic_x86_arm:/ # mkdir /data/data/com.example.waibucunchu/dat ...

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

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

  6. Linux,常用shell命令【删除文件或目录】

    rm (remove)删除文件或目录 rm -d (-directory) #直接把需删除的目录的硬连接数据删成0,删除该目录 rm -f (--force) #强制删除文件或目录:忽略不存在的文件, ...

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

    答:cat file | awk '{$1=null;print $0}' (删除第一列) 转载于:https://www.cnblogs.com/dakewei/p/10437797.html

  8. linux查找并删除文件

    sudo find / -maxdepth 3 -name "*.git" |xargs rm -rf

  9. adb shell 书籍_开发必备---你应该知道的一些 ADB 命令

    版权声明:本文为LooperJing原创文章,转载请注明出处! 一.设备相关 1.adb devices 显示连接到计算机的设备 List of devices attached be34d81e d ...

最新文章

  1. Tengine Web服务器概述
  2. 深度强化学习的 18 个关键问题 | PaperDaily #30
  3. gulp-babel 阻止了js文件编译的进程?
  4. UNIX网络编程 卷2 源代码使用
  5. 互斥锁、死锁、递归锁、信号量、Event
  6. php遍历文件夹下文件内容_PHP递归遍历指定文件夹内的文件实现方法
  7. ★LeetCode(627)——交换工资(MySQL)
  8. 北京发布人工智能产业政策,该如何高效关注行业动态、把握新机遇?
  9. flash作业_在线作业产品的基本构成与逻辑分解
  10. 一个老程序员“伯伯”的独白
  11. 智能网联汽车测试场景数据车载采集平台搭建要求及方法
  12. 局域网 git服务器 虚拟机,GitLab服务器傻瓜式搭建教程
  13. mysql translate 函数_Oracle字符串函数-Translate()总结
  14. 实践:服务器编写/系统架构/cache
  15. [转]Cryengine渲染引擎剖析
  16. 计算机2.0培训心得,信息2.0培训心得体会
  17. 友盟集成微信授权登录,切换微信账号,登录无法切换微信信息问题
  18. 《用计算机画画》教学设计,第8课《简简单单画幅画》教学设计
  19. Pytorch中的model.modules()和model.children()的区别
  20. 单点登录-基于JWT机制的单点登录

热门文章

  1. gpio 树莓派3a+_树莓派4正式发布:35美元起售!真香
  2. 2021年最值得推荐的13个提高开发效率工具,程序员必备
  3. 避坑指南!数据分析最容易被忽略的10个错误
  4. 女生不能学理科?python+数据可视化分析15万考生的成绩,刷新了我的认知
  5. Ribbon客户端负载均衡
  6. eclipsevue代码怎么运行_打了多年的单片机调试断点到底应该怎么设置? | 颠覆认知...
  7. 在一个html中使用另一个html数据,如何为某些HTML标签存储任意数据
  8. 简单java数组程序_java(数组及常用简单算法 )
  9. 并注册烧写钩子 获取启动介质类型_PyTorch中对张量登记注册反向传播的钩子函数,并展示调用顺序...
  10. 七牛切片视频php,音视频切片(HLS)