mirror of https://github.com/axmolengine/axmol.git
for test close project in cocos-console-test.py.
This commit is contained in:
parent
686ed5dfa1
commit
d18ee12678
|
@ -5,31 +5,33 @@
|
|||
import os
|
||||
import sys
|
||||
import json
|
||||
|
||||
import time
|
||||
|
||||
# get payload argvs
|
||||
console_param = '[console create]'
|
||||
console_param = '[console run]'
|
||||
# payload = ''
|
||||
if os.environ.has_key('payload'):
|
||||
payload_str = os.environ['payload']
|
||||
payload = json.loads(payload_str)
|
||||
if payload.has_key('console'):
|
||||
console_param = payload['console']
|
||||
console_param = console_param[1:len(strConsole)-1]
|
||||
console_param = console_param[1:len(console_param)-1]
|
||||
print 'console_param:',console_param
|
||||
|
||||
console_param_arr = console_param.split(' ')
|
||||
|
||||
project_types = ['cpp', 'lua']
|
||||
# project_types = ['cpp', 'lua']
|
||||
project_types = ['cpp']
|
||||
PROJ_SUFFIX = 'Proj'
|
||||
phonePlats = ['mac','ios','android']
|
||||
# phonePlats = ['mac','ios','android']
|
||||
phonePlats = ['ios']
|
||||
|
||||
#need use console's position, perhaps should be set an env-param
|
||||
cocos_console_dir = 'tools/cocos2d-console/bin/'
|
||||
|
||||
#now cocos2d-console suport different run on Platforms, e.g: only run android on win
|
||||
runSupport = {
|
||||
'darwin' : [1, 1, 1],
|
||||
'darwin' : [1, 1, 0],
|
||||
'win' : [0, 0, 1],
|
||||
'linux' : [0, 0, 1]
|
||||
}
|
||||
|
@ -56,6 +58,36 @@ def create_project():
|
|||
print proj,'cmd:',cmd
|
||||
info_create = os.system(cmd) #call cmd on win is diff
|
||||
print 'create project',proj,' is:', not info_create
|
||||
|
||||
def getAppPID(name):
|
||||
cmd = 'ps -eo pid,comm | grep '+name
|
||||
output = os.popen(cmd)
|
||||
result = output.read()
|
||||
arrProcess = result.split('\n')
|
||||
print 'arrProcess:', arrProcess
|
||||
def getProcessId(proInfo):
|
||||
if len(proInfo) > 0:
|
||||
arrInfo = proInfo.split(' ')
|
||||
return int(arrInfo[0])
|
||||
return -1
|
||||
arrProIdx = []
|
||||
for content in arrProcess:
|
||||
idx = getProcessId(content)
|
||||
if idx > 0:
|
||||
arrProIdx.append(idx)
|
||||
return arrProIdx
|
||||
def close_proj(proj):
|
||||
print 'close running project'
|
||||
if curPlat == 'darwin':
|
||||
print 'will close proj:',proj,', on',curPlat
|
||||
arrPids = getAppPID(proj+PROJ_SUFFIX)
|
||||
print 'arrPids:', arrPids
|
||||
for pid in arrPids:
|
||||
cmd = 'kill '
|
||||
cmd += str(pid)
|
||||
print 'cmd:',cmd
|
||||
os.system(cmd)
|
||||
|
||||
def build_run():
|
||||
print 'will build and run'
|
||||
for proj in project_types:
|
||||
|
@ -66,6 +98,10 @@ def build_run():
|
|||
if runSupport[curPlat][idx]:
|
||||
info_run = os.system(cmd)
|
||||
print 'run project', proj, 'is:', not info_run
|
||||
if info_run == 0:
|
||||
time.sleep(5)
|
||||
close_proj(proj)
|
||||
time.sleep(2)
|
||||
idx += 1
|
||||
|
||||
def main():
|
||||
|
@ -73,6 +109,7 @@ def main():
|
|||
create_project()
|
||||
if console_param_arr.count('run'):
|
||||
build_run()
|
||||
# close_proj('cpp')
|
||||
|
||||
# -------------- main --------------
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Reference in New Issue