Merge branch 'develop' of https://github.com/cocos2d/cocos2d-x into develop_new_fix

This commit is contained in:
samuele3hu 2014-03-13 17:53:43 +08:00
commit 2e7b3331a5
2 changed files with 145 additions and 0 deletions

View File

@ -0,0 +1,87 @@
#!/usr/bin/python
#create new project by cocos-console
#build new project and run
import os
import sys
project_types = ['cpp', 'lua']
PROJ_SUFFIX = 'Proj'
phonePlats = ['mac','ios','android']
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],
'win' : [0, 0, 1],
'linux' : [0, 0, 1]
}
_argvs = sys.argv
print 'input argvs:', _argvs[1], _argvs[2]
_will_create = False
_will_run = False
if _argvs[1]=='create' || _argvs[2]=='create':
_will_create = True
if _argvs[1]=='run' || _argvs[2]=='run':
_will_create = True
_will_run = True
if _will_create == False and _will_run == False:
_will_create = True
_will_run = True
curPlat = sys.platform
if curPlat.find('linux') >= 0:
curPlat = 'linux'
elif curPlat.find('darwin') >= 0:
curPlat = 'darwin'
else:
curPlat = 'win'
print 'current platform is:', curPlat
def clean_project():
for proj in project_types:
cmd = 'rm -rf '+proj+PROJ_SUFFIX
os.system(cmd)
def create_project():
print 'will create_project: '
idx = 0
for proj in project_types:
print 'proj: ', proj
cmd = 'cocos new -l '+proj+' '+proj+PROJ_SUFFIX
print proj,'cmd:',cmd
idx += 1
info_create = os.system(cmd) #call cmd on win is diff
print 'create project',proj,' is:', not info_create
def build_run():
print 'will build and run'
for proj in project_types:
idx = 0
for phone in phonePlats:
cmd = 'cocos run -p '+phone+' -s '+proj+PROJ_SUFFIX
print proj,'cmd:',cmd
if runSupport[curPlat][idx]:
info_run = os.system(cmd)
print 'run project', proj, 'is:', not info_run
idx += 1
def main():
if _will_create:
clean_project()
create_project()
if _will_run:
build_run()
# -------------- main --------------
if __name__ == '__main__':
sys_ret = 0
try:
sys_ret = main()
except:
traceback.print_exc()
sys_ret = 1
finally:
sys.exit(sys_ret)

View File

@ -0,0 +1,58 @@
import jenkinsapi
from jenkinsapi.jenkins import Jenkins
import sys
import time
import os
#check & kill dead buid
def build_time(_job):
#get jenkins-job-watchdog-threshold
threshold = os.environ['jenkins-job-watchdog-threshold']
#Get last build running
build = _job.get_last_build()
running = build.is_running()
print 'build_job:',_job,'running:',running
if not running:
return False
#Get numerical ID of the last build.
buildnu = _job.get_last_buildnumber()
print "buildnumber:#",buildnu
#get nowtime
nowtime = time.strftime('%M',time.localtime(time.time()))
#print 'nowtime:',nowtime
#get build start time
timeb = build.get_timestamp()
#print 'buildtime:',str(timeb)[14:16]
buildtime = int(str(timeb)[14:16])
subtime = 0
if int(nowtime) >= buildtime:
subtime = int(nowtime)-buildtime
else:
subtime = 60-buildtime+int(nowtime)
if subtime > threshold:
#print 'subtime',subtime
#kill dead buid
build.stop()
def main():
username = os.environ['username']
password = os.environ['password']
J = Jenkins('http://115.28.134.83:8000',username,password)
#get all jenkins jobs
for key,job in J.iteritems():
build_time(job)
return(0)
# -------------- main --------------
if __name__ == '__main__':
sys_ret = 0
try:
sys_ret = main()
except:
traceback.print_exc()
sys_ret = 1
finally:
sys.exit(sys_ret)