时间:2021-07-01 10:21:17 帮助过:35人阅读
def Remove_dir(top_dir):
if os.path.exists(top_dir)==False:
print "not exists"
return
if os.path.isdir(top_dir)==False:
print "not a dir"
return
for dir_path,subpaths,files in os.walk(top_dir,False):
for file in files:
file_path=os.path.join(dir_path,file)
print "delete file:%s" %file_path
os.remove(file_path)
print "delete dir:%s" %dir_path
os.rmdir(dir_path)
#调用
Remove_dir(r"C:\Users\Administrator\Desktop\abc")
inputdir = "./tmp"
for path, dir, files in os.walk(inputdir):
for file in files:
if not file.endswith('.apk'):
#print "not apk file."
continue
apkpath = os.path.join(inputdir, file)
cmd = './xxx -d %s' %apkpath
output = os.popen(cmd)
s = set()
#按行查找URL
for line in output:
if operator.contains(line, "http://"):
#print tmp
start = line.index('''http://''')
end = line.index('''"''',start)
url = line[start:end]
s.add(url)
cmd = './yyy -t a.expense.mdk.a.tvd %s' %apkpath
#获取命令执行结果及返回值
status, output = commands.getstatusoutput(cmd)
# print output
if output.startswith('find'):
print output
for url in s:
if url.find('imei')!=-1:
print 'url is %s' %url.strip()
#print '========================='
s = ''