import os
import csv
def searchFrameworks(path):
path = path.strip()
if len(path) < 1:
return ""
searchPath = "find " + path + " -name *.framework"
resStr = os.popen(searchPath).read()
return resStr
def splitFrameworksStr():
exeOutput = []
pathArr = []
fatArchArr = []
filekbs = []
path = "xxx_ios-3.0"
outputStr = searchFrameworks(path)
splitedArr = outputStr.split("\n")
if len(splitedArr) <= 0:
return 0
for item in splitedArr:
itemPath = item.strip()
filePath = itemPath.split("/")[-1]
fileName = filePath.split(".")[0]
commandStr = "lipo -info " + itemPath + "/" + fileName
commandResult = os.popen(commandStr).read()
exeOutput.append(commandResult)
pathArr.append(itemPath)
archStr = commandResult.split(":")[-1]
fatArchArr.append(archStr.strip())
file_space_command = "du -sh " + itemPath
space_result_str = os.popen(file_space_command).read()
first_slash_index = space_result_str.find("/")
space_kb = space_result_str[0:first_slash_index]
filekbs.append(space_kb.strip())
output_file(pathArr, fatArchArr, filekbs)
def output_file(paths, archs, filekbs):
with open("frameworks.csv", "w", newline="") as datacsv:
field_name = ["path", "arch"]
writer = csv.writer(datacsv, dialect=("excel"))
for index, item in enumerate(paths):
writer.writerow([item, archs[index], filekbs[index]])