mirror of https://github.com/axmolengine/axmol.git
Merge pull request #6175 from shujunqiao/cocos-console-test-package
[ci skip]add get package size in cocos-console-test.py.
This commit is contained in:
commit
3ba71c9595
|
@ -13,6 +13,7 @@ import time
|
||||||
import socket
|
import socket
|
||||||
import smtplib
|
import smtplib
|
||||||
from email.mime.text import MIMEText
|
from email.mime.text import MIMEText
|
||||||
|
from os.path import join, getsize
|
||||||
|
|
||||||
# default console_param.
|
# default console_param.
|
||||||
console_param = '[console run]'
|
console_param = '[console run]'
|
||||||
|
@ -71,7 +72,7 @@ cocos_console_dir = 'tools/cocos2d-console/bin/'
|
||||||
|
|
||||||
# now cocos2d-console suport different run on Platforms, e.g: only run android on win
|
# now cocos2d-console suport different run on Platforms, e.g: only run android on win
|
||||||
runSupport = {
|
runSupport = {
|
||||||
'darwin' : {'mac':1,'ios':1,'android':0},
|
'darwin' : {'mac':1,'ios':1,'android':1},
|
||||||
'win' : {'mac':0,'ios':0,'android':1},
|
'win' : {'mac':0,'ios':0,'android':1},
|
||||||
'linux' : {'mac':0,'ios':0,'android':1}
|
'linux' : {'mac':0,'ios':0,'android':1}
|
||||||
}
|
}
|
||||||
|
@ -174,8 +175,11 @@ def appendToResult(content):
|
||||||
global console_result
|
global console_result
|
||||||
console_result = console_result + content
|
console_result = console_result + content
|
||||||
|
|
||||||
|
# if any error
|
||||||
|
ANY_ERROR_IN_RUN = 0
|
||||||
# excute cocos command
|
# excute cocos command
|
||||||
def cocos_project(level):
|
def cocos_project(level):
|
||||||
|
global ANY_ERROR_IN_RUN
|
||||||
print 'will excute cocos_command: ', COCOS_CMD[level], level
|
print 'will excute cocos_command: ', COCOS_CMD[level], level
|
||||||
appendToResult('will excute ' + COCOS_CMD[level] + ' command:'+"\n\r\t")
|
appendToResult('will excute ' + COCOS_CMD[level] + ' command:'+"\n\r\t")
|
||||||
for proj in project_types:
|
for proj in project_types:
|
||||||
|
@ -188,6 +192,7 @@ def cocos_project(level):
|
||||||
time.sleep(12)
|
time.sleep(12)
|
||||||
addConsoleListenOnTCP(proj)
|
addConsoleListenOnTCP(proj)
|
||||||
print 'create project',proj,' is:', not info_create
|
print 'create project',proj,' is:', not info_create
|
||||||
|
ANY_ERROR_IN_RUN = ANY_ERROR_IN_RUN + info_create
|
||||||
appendToResult(' '+cmd +': ' + str(not info_create) + ".\n\r\t")
|
appendToResult(' '+cmd +': ' + str(not info_create) + ".\n\r\t")
|
||||||
else:
|
else:
|
||||||
for phone in phonePlats:
|
for phone in phonePlats:
|
||||||
|
@ -199,18 +204,21 @@ def cocos_project(level):
|
||||||
if runSupport[curPlat][phone]:
|
if runSupport[curPlat][phone]:
|
||||||
info_cmd = os.system(cmd)
|
info_cmd = os.system(cmd)
|
||||||
print 'info '+COCOS_CMD[level]+':', not info_cmd
|
print 'info '+COCOS_CMD[level]+':', not info_cmd
|
||||||
else :
|
appendToResult(' '+cmd +': ' + str(not info_cmd) + ".\n\r\t")
|
||||||
|
else:
|
||||||
if runSupport[curPlat][phone]:
|
if runSupport[curPlat][phone]:
|
||||||
if phone == 'android' and getAndroidDevices() == 0:
|
if phone == 'android' and getAndroidDevices() == 0:
|
||||||
print 'no android device, please checkout the device is running ok.'
|
strInfo = 'no android device, please checkout the device is running ok.'
|
||||||
continue
|
print strInfo
|
||||||
info_cmd = os.system(cmd)
|
# appendToResult(' '+strInfo+"\n\r\t")
|
||||||
print 'info '+COCOS_CMD[level]+':', not info_cmd
|
else:
|
||||||
if level == ENUM_PARAM.run:
|
info_cmd = os.system(cmd)
|
||||||
time.sleep(20)
|
print 'info '+COCOS_CMD[level]+':', not info_cmd
|
||||||
strClose = close_proj(proj, phone)
|
if level == ENUM_PARAM.run:
|
||||||
appendToResult(' '+strClose+"\n\r\t")
|
time.sleep(20)
|
||||||
appendToResult(' '+cmd +': ' + str(not info_cmd) + ".\n\r\t")
|
strClose = close_proj(proj, phone)
|
||||||
|
appendToResult(' '+strClose+"\n\r\t")
|
||||||
|
appendToResult(' '+cmd +': ' + str(not info_cmd) + ".\n\r\t")
|
||||||
|
|
||||||
# build and run according to params of provided.(lv_ignore: e.g:ignore new)
|
# build and run according to params of provided.(lv_ignore: e.g:ignore new)
|
||||||
def build_run(lv_ignore):
|
def build_run(lv_ignore):
|
||||||
|
@ -232,9 +240,9 @@ def start_android_simulator():
|
||||||
return
|
return
|
||||||
if cocos_param >= LEVEL_COCOS[ENUM_PARAM.deploy]:
|
if cocos_param >= LEVEL_COCOS[ENUM_PARAM.deploy]:
|
||||||
cmd_start = [ 'emulator -avd '+ANDROID_SIMULATOR_NAME ]
|
cmd_start = [ 'emulator -avd '+ANDROID_SIMULATOR_NAME ]
|
||||||
print 'cmd_start:', cmd_start
|
# print 'cmd_start:', cmd_start
|
||||||
info_start = subprocess.Popen(cmd_start, stdin=subprocess.PIPE, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
# info_start = subprocess.Popen(cmd_start, stdin=subprocess.PIPE, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
print 'start an android simulator:', not info_start
|
# print 'start an android simulator:', not info_start
|
||||||
|
|
||||||
# send email
|
# send email
|
||||||
EMAIL_KEYS={
|
EMAIL_KEYS={
|
||||||
|
@ -285,16 +293,48 @@ def send_mail(to_list,sub,title,content):
|
||||||
def sendEmail(msg):
|
def sendEmail(msg):
|
||||||
send_mail(OBJ_EMAIL_INFO[EMAIL_KEYS[4]], "cocos-console-test result", 'for error.', msg)
|
send_mail(OBJ_EMAIL_INFO[EMAIL_KEYS[4]], "cocos-console-test result", 'for error.', msg)
|
||||||
|
|
||||||
|
# get package size
|
||||||
|
def getdirsize(dir):
|
||||||
|
size = 0L
|
||||||
|
for root, dirs, files in os.walk(dir):
|
||||||
|
size += sum([getsize(join(root, name)) for name in files])
|
||||||
|
return size
|
||||||
|
APP_FILE_DIR = {
|
||||||
|
'cpp':'bin/debug/',
|
||||||
|
'lua':'runtime/'
|
||||||
|
}
|
||||||
|
APP_FILE_SUFFIX = {
|
||||||
|
'mac':'.app',
|
||||||
|
'ios':'.app',
|
||||||
|
'android':'-debug-unaligned.apk'
|
||||||
|
}
|
||||||
|
def getPackageSize():
|
||||||
|
for proj in project_types:
|
||||||
|
for phone in phonePlats:
|
||||||
|
# if runSupport[curPlat][phone]:
|
||||||
|
package_path = './'+proj+PROJ_SUFFIX+'/'+APP_FILE_DIR[proj]+phone+'/'+proj+PROJ_SUFFIX+APP_FILE_SUFFIX[phone]
|
||||||
|
print 'package_path', package_path
|
||||||
|
package_size = 0
|
||||||
|
if os.path.isfile(package_path):
|
||||||
|
package_size = os.path.getsize(package_path);
|
||||||
|
else:
|
||||||
|
package_size = getdirsize(package_path);
|
||||||
|
strSize = 'size of '+proj+PROJ_SUFFIX+' '+phone+' is:'+str(package_size/(1024))+'KB'+'\n\t'
|
||||||
|
print 'strSize:', strSize
|
||||||
|
appendToResult(strSize)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
print 'in main:'
|
print 'in main:'
|
||||||
# start_android_simulator()
|
# start_android_simulator()
|
||||||
print 'will build_run:'
|
print 'will build_run:'
|
||||||
build_run(-1)
|
build_run(-1)
|
||||||
print 'end build run.'
|
print 'ANY_ERROR_IN_RUN:', ANY_ERROR_IN_RUN
|
||||||
|
print 'end build run. and get package size.'
|
||||||
|
getPackageSize()
|
||||||
print 'will send email:'
|
print 'will send email:'
|
||||||
if OBJ_EMAIL_INFO[ EMAIL_KEYS[5] ]:
|
|
||||||
sendEmail(console_result)
|
|
||||||
print 'console_result:', console_result
|
print 'console_result:', console_result
|
||||||
|
if OBJ_EMAIL_INFO[ EMAIL_KEYS[5] ] or ANY_ERROR_IN_RUN:
|
||||||
|
sendEmail(console_result)
|
||||||
|
|
||||||
# -------------- main --------------
|
# -------------- main --------------
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Reference in New Issue