前言
碌者劳其心力,懒人使用工具。程序员作为懒人推动社会进步,有目共睹。
adb 已提供了开发者可以使用的全部工具,但是重复执行一系列adb命令也令人心烦,所以,如果业务需求固定,直接在python脚
本执行adb命令。
核心代码很简单
cmd = 'adb shell'
os.system(cmd)
1.业务需求: 执行应用卸载及删除指定目录
Python学习交流Q群:906715085###
#!/usr/bin/python
import subprocess
import os, sys
import getopt
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
if __name__ == '__main__':
""" change commands and add shell"""
tag = ''
try:
opt, args = getopt.getopt(sys.argv[1:], "ht:", ['pkg', 'help'])
for op, value in opt:
if op in ("-t", "--pkg"):
tag = value
if op in ("-h", "--help"):
print "Usage: main_app_clean.py -t APP_PKG_NAME"
print "Options:"
print " -t APP_PKG_NAME should be a bundle id !"
print ""
print "Sample : ./main_app_clean.py -t <bundle id>"
print ""
sys.exit() except getopt.GetoptError:
print "Error: Could not find the args."
print "Usage: main_app_clean.py -t APP_PKG_NAME"
print "Options:"
print