# -*- coding: utf-8 -*-
#python
'''
Created on 2014-1-15
@author: jhua50x
This script is for get apk information with aapt tool
'''
import sys
import os
import glob
import time
AAPT_COMMAND='.\\aapt\\aapt d badging'
APK_FOLDER='E:\WW03\googleplay'
APK_INFO_FILE='output.csv'
TEMP='temp.txt'
INFO = "[INFO]: " #print info lab
ERROR = "**ERROR**: " #print error info lab
DEBUG = "[DEBUG]: " #print debug info lab
if __name__ == "__main__":
if sys.getdefaultencoding() != 'utf-8':
reload(sys)
sys.setdefaultencoding('utf-8')
print INFO + "Start get package from \"" + APK_FOLDER + "\\*.apk\""
#Get apk file list
file_list = glob.glob(APK_FOLDER + "\\*.apk")
#all apk information will store in APK_INFO_FILE
info_store = open(APK_INFO_FILE, 'w')
#info_store.write(time.strftime('%Y%m%d%H%M%S',time.localtime(time.time())) + '\n')
info_store.write('APK Name, APP ID, App Version, App Type\n')
print('APK Name, APP ID, App Version, App Type')
for file_path in file_list:
apk_name = file_path.split('\\')[-1]
#run aapt d badging apkfile and store the output in temp file
command_output = os.system(AAPT_COMMAND + ' ' + file_path + ' >' + TEMP)
#analysis the output, get apk version
temp_file = open(TEMP, 'r')
app_id = ''
app_version = ''
app_type = ''
for line in temp_file:
#get app_id and app_version from package line
if(line.split(':')[0] == 'package'):
app_id = line.split(' ')[1].split('=')[1]
app_id = app_id[1:-1]
app_version = line.split(' ')[3].split('=')[1]
app_version = app_version[:-2]
continue
if((line.split(':')[0] == 'native-code')
and (line.split(':')[1].find('arm') != -1)
and (line.split(':')[1].find('x86') != -1)):
app_type = 'NDK(Both)'
elif ((line.split(':')[0] == 'native-code')
and (line.split(':')[1].find('arm') != -1)
and (line.split(':')[1].find('x86') == -1)):
app_type = 'NDK(ARM)'
elif ((line.split(':')[0] == 'native-code')
and (line.split(':')[1].find('arm') == -1)
and (line.split(':')[1].find('x86') != -1)):
app_type = 'NDK(IA)'
else:
app_type = 'Dalvik'
print (apk_name + ',' + app_id + ',' + app_version + ',' + app_type)
info_store.write(apk_name + ',' + app_id + ',' + app_version + ',' + app_type + '\n')
temp_file.close()
info_store.close()
#python
'''
Created on 2014-1-15
@author: jhua50x
This script is for get apk information with aapt tool
'''
import sys
import os
import glob
import time
AAPT_COMMAND='.\\aapt\\aapt d badging'
APK_FOLDER='E:\WW03\googleplay'
APK_INFO_FILE='output.csv'
TEMP='temp.txt'
INFO = "[INFO]: " #print info lab
ERROR = "**ERROR**: " #print error info lab
DEBUG = "[DEBUG]: " #print debug info lab
if __name__ == "__main__":
if sys.getdefaultencoding() != 'utf-8':
reload(sys)
sys.setdefaultencoding('utf-8')
print INFO + "Start get package from \"" + APK_FOLDER + "\\*.apk\""
#Get apk file list
file_list = glob.glob(APK_FOLDER + "\\*.apk")
#all apk information will store in APK_INFO_FILE
info_store = open(APK_INFO_FILE, 'w')
#info_store.write(time.strftime('%Y%m%d%H%M%S',time.localtime(time.time())) + '\n')
info_store.write('APK Name, APP ID, App Version, App Type\n')
print('APK Name, APP ID, App Version, App Type')
for file_path in file_list:
apk_name = file_path.split('\\')[-1]
#run aapt d badging apkfile and store the output in temp file
command_output = os.system(AAPT_COMMAND + ' ' + file_path + ' >' + TEMP)
#analysis the output, get apk version
temp_file = open(TEMP, 'r')
app_id = ''
app_version = ''
app_type = ''
for line in temp_file:
#get app_id and app_version from package line
if(line.split(':')[0] == 'package'):
app_id = line.split(' ')[1].split('=')[1]
app_id = app_id[1:-1]
app_version = line.split(' ')[3].split('=')[1]
app_version = app_version[:-2]
continue
if((line.split(':')[0] == 'native-code')
and (line.split(':')[1].find('arm') != -1)
and (line.split(':')[1].find('x86') != -1)):
app_type = 'NDK(Both)'
elif ((line.split(':')[0] == 'native-code')
and (line.split(':')[1].find('arm') != -1)
and (line.split(':')[1].find('x86') == -1)):
app_type = 'NDK(ARM)'
elif ((line.split(':')[0] == 'native-code')
and (line.split(':')[1].find('arm') == -1)
and (line.split(':')[1].find('x86') != -1)):
app_type = 'NDK(IA)'
else:
app_type = 'Dalvik'
print (apk_name + ',' + app_id + ',' + app_version + ',' + app_type)
info_store.write(apk_name + ',' + app_id + ',' + app_version + ',' + app_type + '\n')
temp_file.close()
info_store.close()