python 杀进程 判断文件是否存在 查看进程
2015-08-07 16:33
597 查看
adb用最高权限杀进程
adb shell "su -c "kill 16276""
获取手机目录文件
adb shell ls mnt/shell/emulated/0/
查看进程
adb -s NX510J shell ps |find "com.kugou"
#ls //列表显示当前文件夹内容
#rm -r xxx //删除名字为xxx的文件夹及其里面的所有文件
#rm xxx //删除文件xxx
#rmdir xxx //删除xxx的文件夹
#mkdir -p xxx //递归创建xxx的文件夹
#cp [选项] [来源文件] [目的文件],-d 复制一个快捷方式/-r 复制一个目录/-i 对一个存在的文件,询问是否覆盖
#mv [选项] [来源文件] [目标文件],-u 目标文件存在时才会生效,如果源文件比目标文件新才会移动/-i 对一个存在的文件,询问是否覆盖;
复制文件:
复制一个文件或目录到设备:
adb
push <source> <destination></destination></source>
如:adb
push update.zip /sdcard/
从设备上复制一个文件或目录:
adb
pull <source> <destination></destination></source>
如:adb
pull /sdcard/update.zip.
def IsContainFile(self,strtmp):
"""判断手机路径下是否存在文件
@param strtmp: 查看文件是否存在手机,多个文件用';'。默认路径:mnt/shell/emulated/0/
"""
strlog = ""
strfile = strtmp.split(';')
logcmd = "adb shell ls mnt/shell/emulated/0/"
Popen = subprocess.Popen(logcmd, stdout=subprocess.PIPE, shell=True)
sleep(1)
//等待subprocess执行
while True:
next_line = Popen.stdout.readline()
if next_line == '' and Popen.poll() != None:
break
strlog = strlog + next_line
for file in strfile:
if strlog.find(file) >= 0:
pass
else:
return False
return True
def GetProcess(strpro="com.kugou"):
"""获取进程ID
@param strpro: 进程的名字
"""
logcmd = "adb shell ps |find " + '"' +strpro +'"'
proid = []
strtmp = []
Popen = subprocess.Popen(logcmd, stdout=subprocess.PIPE, shell=True)
while True:
next_line = Popen.stdout.readline()
if next_line == '' and Popen.poll() != None:
break
strtmp = next_line.split(' ');
proid.append(strtmp[3])
if len(proid)>0:
return proid
else:
return False
def killProcess(strpro):
"""获取进程ID
@param strpro: 进程的PID,数组
"""
for strtmp in strpro:
subprocess.call('adb shell "su -c "kill %s""' %strtmp)
adb shell "su -c "kill 16276""
获取手机目录文件
adb shell ls mnt/shell/emulated/0/
查看进程
adb -s NX510J shell ps |find "com.kugou"
#ls //列表显示当前文件夹内容
#rm -r xxx //删除名字为xxx的文件夹及其里面的所有文件
#rm xxx //删除文件xxx
#rmdir xxx //删除xxx的文件夹
#mkdir -p xxx //递归创建xxx的文件夹
#cp [选项] [来源文件] [目的文件],-d 复制一个快捷方式/-r 复制一个目录/-i 对一个存在的文件,询问是否覆盖
#mv [选项] [来源文件] [目标文件],-u 目标文件存在时才会生效,如果源文件比目标文件新才会移动/-i 对一个存在的文件,询问是否覆盖;
复制文件:
复制一个文件或目录到设备:
adb
push <source> <destination></destination></source>
如:adb
push update.zip /sdcard/
从设备上复制一个文件或目录:
adb
pull <source> <destination></destination></source>
如:adb
pull /sdcard/update.zip.
def IsContainFile(self,strtmp):
"""判断手机路径下是否存在文件
@param strtmp: 查看文件是否存在手机,多个文件用';'。默认路径:mnt/shell/emulated/0/
"""
strlog = ""
strfile = strtmp.split(';')
logcmd = "adb shell ls mnt/shell/emulated/0/"
Popen = subprocess.Popen(logcmd, stdout=subprocess.PIPE, shell=True)
sleep(1)
//等待subprocess执行
while True:
next_line = Popen.stdout.readline()
if next_line == '' and Popen.poll() != None:
break
strlog = strlog + next_line
for file in strfile:
if strlog.find(file) >= 0:
pass
else:
return False
return True
def GetProcess(strpro="com.kugou"):
"""获取进程ID
@param strpro: 进程的名字
"""
logcmd = "adb shell ps |find " + '"' +strpro +'"'
proid = []
strtmp = []
Popen = subprocess.Popen(logcmd, stdout=subprocess.PIPE, shell=True)
while True:
next_line = Popen.stdout.readline()
if next_line == '' and Popen.poll() != None:
break
strtmp = next_line.split(' ');
proid.append(strtmp[3])
if len(proid)>0:
return proid
else:
return False
def killProcess(strpro):
"""获取进程ID
@param strpro: 进程的PID,数组
"""
for strtmp in strpro:
subprocess.call('adb shell "su -c "kill %s""' %strtmp)
相关文章推荐
- python引用和复制一个对象
- python udp 广播
- Python3 Counter类计算list中元素出现次数
- Python3 列表List或元组tuple中元素分解(赋值操作)
- Python 的列表排序
- 【Python】[函数] 函数的参数与递归函数
- python udpserver decorator 修饰类
- Python学习笔记06
- python之__name__属性
- python trackback的使用心得
- Python学习笔记
- 20150805-20150807 tradeDate-----python
- python none,null,,,,,类型
- python none,null,,,,,类型
- Python 传参
- Python长字符串的打印
- python - Local variable referenced before assignment
- Python安装
- Mac 下python安装virtualen与配置
- windows下python文件与文件夹操作