您的位置:首页 > 移动开发

【Python开发】检测app使用了多少个xib和js的脚本(python)

2016-08-14 00:04 766 查看
#!/usr/bin/env python
# coding=utf-8
import os, sys

def countTargetFile(targetDir):
resultStr = ''
targetTypes = ['.nib', '.m', '.js']
for targetType in targetTypes:
targetCount = 0
for root, dirs, files in os.walk(targetDir):
for file in files:
if file.endswith(targetType):
print os.path.join(root, file)
targetCount += 1
oneResult = 'type = ' + targetType + ', target count = ' + str(targetCount)
print oneResult
resultStr += oneResult + '\n'
return resultStr

def deal(baseDir, filename):
print 'process file:' + baseDir + filename
tmpDir = os.getcwd() + '/unzip_folders/' + filename.replace(' ', '_')
print tmpDir
try:
os.mkdir(tmpDir)
zipFile = tmpDir + '/' + 'tmp.zip'
command = 'cp ' + baseDir + filename.replace(' ', '\ ') + ' ' + zipFile
os.system(command)
command = 'unzip ' + zipFile + ' -d ' + tmpDir
print command
os.system(command)
except OSError:
print 'file exist, ignore'

resultStr = countTargetFile(tmpDir + '/Payload')
file = open(tmpDir.replace('.ipa','') +  '_result.txt', 'w')
file.write(filename + ':\n')
file.write(resultStr)
file.write('\n')
file.close()

def process():
baseDir = os.getcwd()
targetFiles = os.listdir('./ipa_folders')
print targetFiles
for oneFile in targetFiles:
if oneFile.endswith('.ipa'):
deal(baseDir + '/ipa_folders/', oneFile)

if __name__ == '__main__':
process()
print 'over'


转载地址:脚本
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: