mirror of https://github.com/axmolengine/axmol.git
fixed indentation of Python files
- Changed tabs to spaces - Changed 2 spaces to 4 spaces
This commit is contained in:
parent
6edf125c4e
commit
0854f980fa
|
@ -9,14 +9,14 @@ import shutil
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
|
||||||
def get_num_of_cpu():
|
def get_num_of_cpu():
|
||||||
''' The build process can be accelerated by running multiple concurrent job processes using the -j-option.
|
''' The build process can be accelerated by running multiple concurrent job processes using the -j-option.
|
||||||
'''
|
'''
|
||||||
try:
|
try:
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
return multiprocessing.cpu_count()
|
return multiprocessing.cpu_count()
|
||||||
except Exception:
|
except Exception:
|
||||||
print "Can't know cpuinfo, use default 1 cpu"
|
print "Can't know cpuinfo, use default 1 cpu"
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
def check_environment_variables_sdk():
|
def check_environment_variables_sdk():
|
||||||
''' Checking the environment ANDROID_SDK_ROOT, which will be used for building
|
''' Checking the environment ANDROID_SDK_ROOT, which will be used for building
|
||||||
|
@ -69,17 +69,17 @@ def do_build(cocos_root, ndk_root, app_android_root,ndk_build_param,sdk_root,and
|
||||||
if os.system(command) != 0:
|
if os.system(command) != 0:
|
||||||
raise Exception("Build dynamic library for project [ " + app_android_root + " ] fails!")
|
raise Exception("Build dynamic library for project [ " + app_android_root + " ] fails!")
|
||||||
elif android_platform is not None:
|
elif android_platform is not None:
|
||||||
sdk_tool_path = os.path.join(sdk_root, "tools/android")
|
sdk_tool_path = os.path.join(sdk_root, "tools/android")
|
||||||
cocoslib_path = os.path.join(cocos_root, "cocos/platform/android/java")
|
cocoslib_path = os.path.join(cocos_root, "cocos/platform/android/java")
|
||||||
command = '%s update lib-project -t %s -p %s' % (sdk_tool_path,android_platform,cocoslib_path)
|
command = '%s update lib-project -t %s -p %s' % (sdk_tool_path,android_platform,cocoslib_path)
|
||||||
if os.system(command) != 0:
|
if os.system(command) != 0:
|
||||||
raise Exception("update cocos lib-project [ " + cocoslib_path + " ] fails!")
|
raise Exception("update cocos lib-project [ " + cocoslib_path + " ] fails!")
|
||||||
command = '%s update project -t %s -p %s -s' % (sdk_tool_path,android_platform,app_android_root)
|
command = '%s update project -t %s -p %s -s' % (sdk_tool_path,android_platform,app_android_root)
|
||||||
if os.system(command) != 0:
|
if os.system(command) != 0:
|
||||||
raise Exception("update project [ " + app_android_root + " ] fails!")
|
raise Exception("update project [ " + app_android_root + " ] fails!")
|
||||||
buildfile_path = os.path.join(app_android_root, "build.xml")
|
buildfile_path = os.path.join(app_android_root, "build.xml")
|
||||||
command = 'ant clean %s -f %s -Dsdk.dir=%s' % (build_mode,buildfile_path,sdk_root)
|
command = 'ant clean %s -f %s -Dsdk.dir=%s' % (build_mode,buildfile_path,sdk_root)
|
||||||
os.system(command)
|
os.system(command)
|
||||||
|
|
||||||
def copy_files(src, dst):
|
def copy_files(src, dst):
|
||||||
|
|
||||||
|
@ -119,15 +119,15 @@ def build(ndk_build_param,android_platform,build_mode):
|
||||||
copy_resources(app_android_root)
|
copy_resources(app_android_root)
|
||||||
|
|
||||||
if android_platform is not None:
|
if android_platform is not None:
|
||||||
sdk_root = check_environment_variables_sdk()
|
sdk_root = check_environment_variables_sdk()
|
||||||
if android_platform.isdigit():
|
if android_platform.isdigit():
|
||||||
android_platform = 'android-'+android_platform
|
android_platform = 'android-'+android_platform
|
||||||
else:
|
else:
|
||||||
print 'please use vaild android platform'
|
print 'please use vaild android platform'
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
if build_mode is None:
|
if build_mode is None:
|
||||||
build_mode = 'debug'
|
build_mode = 'debug'
|
||||||
elif build_mode != 'release':
|
elif build_mode != 'release':
|
||||||
build_mode = 'debug'
|
build_mode = 'debug'
|
||||||
|
|
||||||
|
|
|
@ -21,153 +21,153 @@ sleep_time = 1.5
|
||||||
|
|
||||||
#
|
#
|
||||||
def getADBDeviceIP():
|
def getADBDeviceIP():
|
||||||
output = os.popen("adb shell netcfg")
|
output = os.popen("adb shell netcfg")
|
||||||
configs = output.read().split('\r\n')
|
configs = output.read().split('\r\n')
|
||||||
for l in configs:
|
for l in configs:
|
||||||
items = l.split()
|
items = l.split()
|
||||||
if(items[1] == 'UP'):
|
if(items[1] == 'UP'):
|
||||||
if(items[2] != '127.0.0.1'):
|
if(items[2] != '127.0.0.1'):
|
||||||
return items[2]
|
return items[2]
|
||||||
|
|
||||||
def autotest(type):
|
def autotest(type):
|
||||||
soc = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
|
soc = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
|
||||||
if type == TYPE_MAC:
|
if type == TYPE_MAC:
|
||||||
soc.connect((HOST_MAC, PORT))
|
soc.connect((HOST_MAC, PORT))
|
||||||
if type == TYPE_ANDROID:
|
if type == TYPE_ANDROID:
|
||||||
HOST_ANDROID = getADBDeviceIP()
|
HOST_ANDROID = getADBDeviceIP()
|
||||||
soc.connect((HOST_ANDROID, PORT))
|
soc.connect((HOST_ANDROID, PORT))
|
||||||
if type == TYPE_IOS:
|
if type == TYPE_IOS:
|
||||||
soc.connect((HOST_IOS, PORT))
|
soc.connect((HOST_IOS, PORT))
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
print 'autotest run:'
|
print 'autotest run:'
|
||||||
soc.send('autotest run\r\n')
|
soc.send('autotest run\r\n')
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
data = soc.recv(1024)
|
data = soc.recv(1024)
|
||||||
print data
|
print data
|
||||||
if data == 'TestEnd':
|
if data == 'TestEnd':
|
||||||
lastTestInfo = True
|
lastTestInfo = True
|
||||||
break
|
break
|
||||||
global lastTestInfo
|
global lastTestInfo
|
||||||
if len(data) > len('\n') :
|
if len(data) > len('\n') :
|
||||||
lastTestInfo = data
|
lastTestInfo = data
|
||||||
if not data: break
|
if not data: break
|
||||||
|
|
||||||
soc.send('director end\r\n')
|
soc.send('director end\r\n')
|
||||||
print 'test end and close socket.'
|
print 'test end and close socket.'
|
||||||
soc.close()
|
soc.close()
|
||||||
|
|
||||||
#----------------autotest build and run----------------#
|
#----------------autotest build and run----------------#
|
||||||
def MAC_BUILD():
|
def MAC_BUILD():
|
||||||
def cleanProj():
|
def cleanProj():
|
||||||
infoClean = os.system('xcodebuild -project ./build/cocos2d_tests.xcodeproj -target cpp-tests\ Mac clean')
|
infoClean = os.system('xcodebuild -project ./build/cocos2d_tests.xcodeproj -target cpp-tests\ Mac clean')
|
||||||
print 'infoClean: ', infoClean
|
print 'infoClean: ', infoClean
|
||||||
if infoClean != 0:
|
if infoClean != 0:
|
||||||
return False
|
return False
|
||||||
time.sleep(sleep_time)
|
time.sleep(sleep_time)
|
||||||
return True
|
return True
|
||||||
def buildProj():
|
def buildProj():
|
||||||
infoBuild = os.system('xcodebuild -project ./build/cocos2d_tests.xcodeproj -target cpp-tests\ Mac')
|
infoBuild = os.system('xcodebuild -project ./build/cocos2d_tests.xcodeproj -target cpp-tests\ Mac')
|
||||||
print 'infoBuild: ', infoBuild
|
print 'infoBuild: ', infoBuild
|
||||||
if infoBuild != 0:
|
if infoBuild != 0:
|
||||||
return False
|
return False
|
||||||
time.sleep(sleep_time)
|
time.sleep(sleep_time)
|
||||||
return True
|
return True
|
||||||
def openProj():
|
def openProj():
|
||||||
cmd = 'open ./build/build/Debug/cpp-tests\ Mac.app'
|
cmd = 'open ./build/build/Debug/cpp-tests\ Mac.app'
|
||||||
print 'cmd: ', cmd
|
print 'cmd: ', cmd
|
||||||
infoOpen = os.system(cmd)
|
infoOpen = os.system(cmd)
|
||||||
print 'infoOpen: ', infoOpen
|
print 'infoOpen: ', infoOpen
|
||||||
if infoOpen != 0:
|
if infoOpen != 0:
|
||||||
return False
|
return False
|
||||||
time.sleep(sleep_time)
|
time.sleep(sleep_time)
|
||||||
return True
|
return True
|
||||||
def buildAndRun():
|
def buildAndRun():
|
||||||
if not cleanProj():
|
if not cleanProj():
|
||||||
print '**CLEAN FAILED**'
|
print '**CLEAN FAILED**'
|
||||||
if not buildProj():
|
if not buildProj():
|
||||||
print '**BUILD FAILED**'
|
print '**BUILD FAILED**'
|
||||||
return False
|
return False
|
||||||
if not openProj():
|
if not openProj():
|
||||||
return False
|
return False
|
||||||
time.sleep(sleep_time)
|
time.sleep(sleep_time)
|
||||||
return True
|
return True
|
||||||
return buildAndRun()
|
return buildAndRun()
|
||||||
#----------------autotest build and run end----------------#
|
#----------------autotest build and run end----------------#
|
||||||
|
|
||||||
PATH_ANDROID_SRC = 'tests/cpp-tests/proj.android/'
|
PATH_ANDROID_SRC = 'tests/cpp-tests/proj.android/'
|
||||||
FILE_ANDROID_DELETE = ['libs','gen','assets','bin','obj']
|
FILE_ANDROID_DELETE = ['libs','gen','assets','bin','obj']
|
||||||
#----------------autotest-android build and run----------------#
|
#----------------autotest-android build and run----------------#
|
||||||
def ANDROID_BUILD():
|
def ANDROID_BUILD():
|
||||||
def checkDevice():
|
def checkDevice():
|
||||||
cmd = 'adb devices'
|
cmd = 'adb devices'
|
||||||
infoDev = os.popen(cmd).readlines()
|
infoDev = os.popen(cmd).readlines()
|
||||||
firstDev = infoDev[1]
|
firstDev = infoDev[1]
|
||||||
if len(firstDev) < 5 or firstDev.find('device') < 0:
|
if len(firstDev) < 5 or firstDev.find('device') < 0:
|
||||||
print 'no android device.'
|
print 'no android device.'
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
print 'device info:', firstDev
|
print 'device info:', firstDev
|
||||||
return True
|
return True
|
||||||
def cleanProj():
|
def cleanProj():
|
||||||
for strFile in FILE_ANDROID_DELETE:
|
for strFile in FILE_ANDROID_DELETE:
|
||||||
infoClean = os.system('rm -rf '+PATH_ANDROID_SRC+strFile)
|
infoClean = os.system('rm -rf '+PATH_ANDROID_SRC+strFile)
|
||||||
infoClean = os.system('adb uninstall org.cocos2dx.cpp_tests');
|
infoClean = os.system('adb uninstall org.cocos2dx.cpp_tests');
|
||||||
print 'infoClean: ', infoClean
|
print 'infoClean: ', infoClean
|
||||||
if infoClean != 0:
|
if infoClean != 0:
|
||||||
print 'clean **CLEAN FAILED**'
|
print 'clean **CLEAN FAILED**'
|
||||||
time.sleep(sleep_time)
|
time.sleep(sleep_time)
|
||||||
def updateProperty():
|
def updateProperty():
|
||||||
infoUpdate = os.system('android update project -p ./cocos/platform/android/java/ -t 12')
|
infoUpdate = os.system('android update project -p ./cocos/platform/android/java/ -t 12')
|
||||||
print 'cocos update:', infoUpdate
|
print 'cocos update:', infoUpdate
|
||||||
infoUpdate = os.system('android update project -p '+PATH_ANDROID_SRC+' -t 12')
|
infoUpdate = os.system('android update project -p '+PATH_ANDROID_SRC+' -t 12')
|
||||||
print 'test update:', infoUpdate
|
print 'test update:', infoUpdate
|
||||||
def buildProj():
|
def buildProj():
|
||||||
infoBuild = os.system('./build/android-build.py -p 13 cpp-tests')
|
infoBuild = os.system('./build/android-build.py -p 13 cpp-tests')
|
||||||
print 'infoBuild cpp_tests: ', infoBuild
|
print 'infoBuild cpp_tests: ', infoBuild
|
||||||
infoBuild = os.system('ant -buildfile '+PATH_ANDROID_SRC+' debug')
|
infoBuild = os.system('ant -buildfile '+PATH_ANDROID_SRC+' debug')
|
||||||
print 'infoBuild: ', infoBuild
|
print 'infoBuild: ', infoBuild
|
||||||
if infoBuild != 0:
|
if infoBuild != 0:
|
||||||
print 'build **BUILD FAILED**'
|
print 'build **BUILD FAILED**'
|
||||||
time.sleep(sleep_time)
|
time.sleep(sleep_time)
|
||||||
return infoBuild
|
return infoBuild
|
||||||
def installProj():
|
def installProj():
|
||||||
cmd = 'adb install '+PATH_ANDROID_SRC+'bin/CppTests-debug.apk'
|
cmd = 'adb install '+PATH_ANDROID_SRC+'bin/CppTests-debug.apk'
|
||||||
infoInstall = os.system(cmd)
|
infoInstall = os.system(cmd)
|
||||||
print 'infoInstall:', infoInstall
|
print 'infoInstall:', infoInstall
|
||||||
if infoInstall != 0:
|
if infoInstall != 0:
|
||||||
print 'install **INSTALL FAILED**'
|
print 'install **INSTALL FAILED**'
|
||||||
return infoInstall
|
return infoInstall
|
||||||
def openProj():
|
def openProj():
|
||||||
cmd = 'adb shell am start -n org.cocos2dx.cpp_tests/org.cocos2dx.cpp_tests.Cocos2dxActivity'
|
cmd = 'adb shell am start -n org.cocos2dx.cpp_tests/org.cocos2dx.cpp_tests.Cocos2dxActivity'
|
||||||
print 'cmd: ', cmd
|
print 'cmd: ', cmd
|
||||||
infoOpen = os.system(cmd)
|
infoOpen = os.system(cmd)
|
||||||
print 'infoOpen: ', infoOpen
|
print 'infoOpen: ', infoOpen
|
||||||
if infoOpen != 0:
|
if infoOpen != 0:
|
||||||
return False
|
return False
|
||||||
time.sleep(sleep_time)
|
time.sleep(sleep_time)
|
||||||
return True
|
return True
|
||||||
def buildAndRun():
|
def buildAndRun():
|
||||||
if not checkDevice():
|
if not checkDevice():
|
||||||
return False
|
return False
|
||||||
cleanProj()
|
cleanProj()
|
||||||
updateProperty()
|
updateProperty()
|
||||||
buildProj()
|
buildProj()
|
||||||
installProj()
|
installProj()
|
||||||
return openProj()
|
return openProj()
|
||||||
return buildAndRun()
|
return buildAndRun()
|
||||||
#----------------autotest-android build and run end----------------#
|
#----------------autotest-android build and run end----------------#
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
print 'will build mac project.'
|
print 'will build mac project.'
|
||||||
suc_build_mac = MAC_BUILD()
|
suc_build_mac = MAC_BUILD()
|
||||||
# print 'will build android project.'
|
# print 'will build android project.'
|
||||||
# suc_build_android = ANDROID_BUILD()
|
# suc_build_android = ANDROID_BUILD()
|
||||||
if suc_build_mac:
|
if suc_build_mac:
|
||||||
autotest(TYPE_MAC)
|
autotest(TYPE_MAC)
|
||||||
if suc_build_android:
|
if suc_build_android:
|
||||||
print 'will run android autotest.'
|
print 'will run android autotest.'
|
||||||
autotest(TYPE_ANDROID)
|
autotest(TYPE_ANDROID)
|
||||||
|
|
||||||
|
|
||||||
# -------------- main --------------
|
# -------------- main --------------
|
||||||
|
|
|
@ -20,10 +20,10 @@ from os.path import join, getsize
|
||||||
console_param = '[console run]'
|
console_param = '[console run]'
|
||||||
# get param from commit.
|
# get param from commit.
|
||||||
if os.environ.has_key('payload'):
|
if os.environ.has_key('payload'):
|
||||||
payload_str = os.environ['payload']
|
payload_str = os.environ['payload']
|
||||||
payload = json.loads(payload_str)
|
payload = json.loads(payload_str)
|
||||||
if payload.has_key('console'):
|
if payload.has_key('console'):
|
||||||
console_param = payload['console']
|
console_param = payload['console']
|
||||||
console_param = console_param[1:len(console_param)-1]
|
console_param = console_param[1:len(console_param)-1]
|
||||||
print 'console_param:',console_param
|
print 'console_param:',console_param
|
||||||
|
|
||||||
|
@ -31,34 +31,34 @@ console_param_arr = console_param.split(' ')
|
||||||
|
|
||||||
# enum command type
|
# enum command type
|
||||||
class ENUM_PARAM:
|
class ENUM_PARAM:
|
||||||
new = 0
|
new = 0
|
||||||
compile = 1
|
compile = 1
|
||||||
deploy = 2
|
deploy = 2
|
||||||
run = 3
|
run = 3
|
||||||
|
|
||||||
# partition different level
|
# partition different level
|
||||||
LEVEL_COCOS = {
|
LEVEL_COCOS = {
|
||||||
ENUM_PARAM.new : 1,
|
ENUM_PARAM.new : 1,
|
||||||
ENUM_PARAM.compile : 2,
|
ENUM_PARAM.compile : 2,
|
||||||
ENUM_PARAM.deploy : 4,
|
ENUM_PARAM.deploy : 4,
|
||||||
ENUM_PARAM.run : 8
|
ENUM_PARAM.run : 8
|
||||||
}
|
}
|
||||||
|
|
||||||
# level's cocos command
|
# level's cocos command
|
||||||
COCOS_CMD = {
|
COCOS_CMD = {
|
||||||
ENUM_PARAM.new:'new',
|
ENUM_PARAM.new:'new',
|
||||||
ENUM_PARAM.compile:'compile',
|
ENUM_PARAM.compile:'compile',
|
||||||
ENUM_PARAM.deploy:'deploy',
|
ENUM_PARAM.deploy:'deploy',
|
||||||
ENUM_PARAM.run:'run'
|
ENUM_PARAM.run:'run'
|
||||||
}
|
}
|
||||||
|
|
||||||
# set cocos_param for run different command
|
# set cocos_param for run different command
|
||||||
cocos_param = 0
|
cocos_param = 0
|
||||||
for level in LEVEL_COCOS:
|
for level in LEVEL_COCOS:
|
||||||
if console_param_arr.count(COCOS_CMD[level]):
|
if console_param_arr.count(COCOS_CMD[level]):
|
||||||
cocos_param = cocos_param + LEVEL_COCOS[level]
|
cocos_param = cocos_param + LEVEL_COCOS[level]
|
||||||
if cocos_param < LEVEL_COCOS[ENUM_PARAM.new]:
|
if cocos_param < LEVEL_COCOS[ENUM_PARAM.new]:
|
||||||
cocos_param = LEVEL_COCOS[ENUM_PARAM.new]
|
cocos_param = LEVEL_COCOS[ENUM_PARAM.new]
|
||||||
print 'cocos_param:', cocos_param
|
print 'cocos_param:', cocos_param
|
||||||
|
|
||||||
# project types
|
# project types
|
||||||
|
@ -73,109 +73,109 @@ 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':1},
|
'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}
|
||||||
}
|
}
|
||||||
|
|
||||||
# get current running system
|
# get current running system
|
||||||
curPlat = sys.platform
|
curPlat = sys.platform
|
||||||
if curPlat.find('linux') >= 0:
|
if curPlat.find('linux') >= 0:
|
||||||
curPlat = 'linux'
|
curPlat = 'linux'
|
||||||
elif curPlat.find('darwin') >= 0:
|
elif curPlat.find('darwin') >= 0:
|
||||||
curPlat = 'darwin'
|
curPlat = 'darwin'
|
||||||
else:
|
else:
|
||||||
curPlat = 'win'
|
curPlat = 'win'
|
||||||
print 'current platform is:', curPlat
|
print 'current platform is:', curPlat
|
||||||
|
|
||||||
# delete project.(will use different system command to delete.just mac now.)
|
# delete project.(will use different system command to delete.just mac now.)
|
||||||
def clean_project():
|
def clean_project():
|
||||||
print 'delete older project.'
|
print 'delete older project.'
|
||||||
for proj in project_types:
|
for proj in project_types:
|
||||||
cmd = 'rm -rf '+proj+PROJ_SUFFIX
|
cmd = 'rm -rf '+proj+PROJ_SUFFIX
|
||||||
os.system(cmd)
|
os.system(cmd)
|
||||||
|
|
||||||
# file path.(for add console listen command.)
|
# file path.(for add console listen command.)
|
||||||
FILE_PATH = '/Classes/AppDelegate.cpp'
|
FILE_PATH = '/Classes/AppDelegate.cpp'
|
||||||
FILE_DIR = {
|
FILE_DIR = {
|
||||||
'cpp':'',
|
'cpp':'',
|
||||||
'lua':'/frameworks/runtime-src'
|
'lua':'/frameworks/runtime-src'
|
||||||
}
|
}
|
||||||
PARSE_WORD = 'director->setDisplayStats(true);'
|
PARSE_WORD = 'director->setDisplayStats(true);'
|
||||||
CONSOLE_COMMAND = 'director->getConsole()->listenOnTCP(5678);'
|
CONSOLE_COMMAND = 'director->getConsole()->listenOnTCP(5678);'
|
||||||
|
|
||||||
# add console listenOnTCP to AppDelegate.cpp.
|
# add console listenOnTCP to AppDelegate.cpp.
|
||||||
def addConsoleListenOnTCP(name):
|
def addConsoleListenOnTCP(name):
|
||||||
filePath = name+PROJ_SUFFIX+FILE_DIR[name]+FILE_PATH
|
filePath = name+PROJ_SUFFIX+FILE_DIR[name]+FILE_PATH
|
||||||
print 'filePath:',filePath
|
print 'filePath:',filePath
|
||||||
strCont = ''
|
strCont = ''
|
||||||
if os.path.isfile(filePath):
|
if os.path.isfile(filePath):
|
||||||
file_object = open(filePath, 'r')
|
file_object = open(filePath, 'r')
|
||||||
strLine = file_object.readline()
|
strLine = file_object.readline()
|
||||||
while strLine:
|
while strLine:
|
||||||
strCont = strCont + strLine
|
strCont = strCont + strLine
|
||||||
if strLine.find(PARSE_WORD) > -1:
|
if strLine.find(PARSE_WORD) > -1:
|
||||||
print 'add console listenOnTCP command.'
|
print 'add console listenOnTCP command.'
|
||||||
strCont = strCont+'\n\t' + CONSOLE_COMMAND + '\n'
|
strCont = strCont+'\n\t' + CONSOLE_COMMAND + '\n'
|
||||||
strLine = file_object.readline()
|
strLine = file_object.readline()
|
||||||
|
|
||||||
file_object.close()
|
file_object.close()
|
||||||
file_object = open(filePath, 'w')
|
file_object = open(filePath, 'w')
|
||||||
file_object.write(strCont)
|
file_object.write(strCont)
|
||||||
file_object.close()
|
file_object.close()
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
else:
|
else:
|
||||||
print 'file is not exist.'
|
print 'file is not exist.'
|
||||||
|
|
||||||
# console result, for record result
|
# console result, for record result
|
||||||
console_result = 'the result of cocos-console-test is:\n\r'
|
console_result = 'the result of cocos-console-test is:\n\r'
|
||||||
|
|
||||||
# get current android devices count.
|
# get current android devices count.
|
||||||
def getAndroidDevices():
|
def getAndroidDevices():
|
||||||
cmd = 'adb devices'
|
cmd = 'adb devices'
|
||||||
info_devices = os.popen(cmd).read()
|
info_devices = os.popen(cmd).read()
|
||||||
arrDevices = info_devices.split('\n')
|
arrDevices = info_devices.split('\n')
|
||||||
del arrDevices[0]
|
del arrDevices[0]
|
||||||
count = 0
|
count = 0
|
||||||
for device in arrDevices:
|
for device in arrDevices:
|
||||||
# e.g: emulator-5554 device, contains 'device', so, min length is len('device')
|
# e.g: emulator-5554 device, contains 'device', so, min length is len('device')
|
||||||
if len(device) > len('device') and (device.find('device') >= 0):
|
if len(device) > len('device') and (device.find('device') >= 0):
|
||||||
count += 1
|
count += 1
|
||||||
return count
|
return count
|
||||||
|
|
||||||
# close running app or exe by using console command.
|
# close running app or exe by using console command.
|
||||||
IP_PHONE = {
|
IP_PHONE = {
|
||||||
'mac':'localhost',
|
'mac':'localhost',
|
||||||
'ios':'localhost'
|
'ios':'localhost'
|
||||||
}
|
}
|
||||||
PORT = 5678
|
PORT = 5678
|
||||||
|
|
||||||
def close_proj(proj, phone):
|
def close_proj(proj, phone):
|
||||||
print 'close running project'
|
print 'close running project'
|
||||||
# connect socket
|
# connect socket
|
||||||
strClose = 'close ' + proj + ' on ' + phone
|
strClose = 'close ' + proj + ' on ' + phone
|
||||||
if IP_PHONE.has_key(phone):
|
if IP_PHONE.has_key(phone):
|
||||||
soc = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
|
soc = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
|
||||||
print proj, phone, IP_PHONE[phone]
|
print proj, phone, IP_PHONE[phone]
|
||||||
try:
|
try:
|
||||||
soc.connect((IP_PHONE[phone], PORT))
|
soc.connect((IP_PHONE[phone], PORT))
|
||||||
cmd = 'director end\r\n'
|
cmd = 'director end\r\n'
|
||||||
print 'cmd close:', cmd
|
print 'cmd close:', cmd
|
||||||
soc.send(cmd)
|
soc.send(cmd)
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
strClose = strClose + ' success.'
|
strClose = strClose + ' success.'
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
print 'socket is not connect.'
|
print 'socket is not connect.'
|
||||||
strClose = strClose + ' failed.' + ' socket is not connect.'
|
strClose = strClose + ' failed.' + ' socket is not connect.'
|
||||||
else:
|
else:
|
||||||
strClose = strClose + ' failed.' + ' no ' +phone+ ' type.'
|
strClose = strClose + ' failed.' + ' no ' +phone+ ' type.'
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
return strClose
|
return strClose
|
||||||
|
|
||||||
# appendToResult
|
# appendToResult
|
||||||
def appendToResult(content):
|
def appendToResult(content):
|
||||||
global console_result
|
global console_result
|
||||||
console_result = console_result + content
|
console_result = console_result + content
|
||||||
|
|
||||||
info_of_close_app = {}
|
info_of_close_app = {}
|
||||||
cur_test_name = ''
|
cur_test_name = ''
|
||||||
|
@ -186,194 +186,194 @@ class myThread(threading.Thread):
|
||||||
run_name = self.getName()
|
run_name = self.getName()
|
||||||
print 'run_name:', run_name
|
print 'run_name:', run_name
|
||||||
if run_name == 'close':
|
if run_name == 'close':
|
||||||
while True:
|
while True:
|
||||||
soc = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
|
soc = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
|
||||||
try:
|
try:
|
||||||
soc.connect(('localhost', PORT))
|
soc.connect(('localhost', PORT))
|
||||||
cmd_close = 'director end\r\n'
|
cmd_close = 'director end\r\n'
|
||||||
print 'cmd close:', cmd_close
|
print 'cmd close:', cmd_close
|
||||||
soc.send(cmd_close)
|
soc.send(cmd_close)
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
global cur_test_name
|
global cur_test_name
|
||||||
print 'cur_test_name:', cur_test_name
|
print 'cur_test_name:', cur_test_name
|
||||||
info_of_close_app[cur_test_name] = True
|
info_of_close_app[cur_test_name] = True
|
||||||
break
|
break
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
|
|
||||||
# if any error
|
# if any error
|
||||||
ANY_ERROR_IN_RUN = 0
|
ANY_ERROR_IN_RUN = 0
|
||||||
# excute cocos command
|
# excute cocos command
|
||||||
def cocos_project(level):
|
def cocos_project(level):
|
||||||
global ANY_ERROR_IN_RUN
|
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:
|
||||||
print 'proj: ', proj
|
print 'proj: ', proj
|
||||||
if level == ENUM_PARAM.new:
|
if level == ENUM_PARAM.new:
|
||||||
cmd = './'+cocos_console_dir+'cocos new -l '+proj+' '+proj+PROJ_SUFFIX
|
cmd = './'+cocos_console_dir+'cocos new -l '+proj+' '+proj+PROJ_SUFFIX
|
||||||
print proj,'cmd:',cmd
|
print proj,'cmd:',cmd
|
||||||
info_create = os.system(cmd) #call cmd on win is diff
|
info_create = os.system(cmd) #call cmd on win is diff
|
||||||
if info_create == 0:
|
if info_create == 0:
|
||||||
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
|
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:
|
||||||
print 'platform is: ', phone
|
print 'platform is: ', phone
|
||||||
cmd = './'+cocos_console_dir+'cocos '+COCOS_CMD[level]+' -s '+proj+PROJ_SUFFIX+' -p '+phone
|
cmd = './'+cocos_console_dir+'cocos '+COCOS_CMD[level]+' -s '+proj+PROJ_SUFFIX+' -p '+phone
|
||||||
print 'cmd:',cmd
|
print 'cmd:',cmd
|
||||||
info_cmd = ''
|
info_cmd = ''
|
||||||
if level == ENUM_PARAM.compile:
|
if level == ENUM_PARAM.compile:
|
||||||
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
|
||||||
appendToResult(' '+cmd +': ' + str(not info_cmd) + ".\n\r\t")
|
appendToResult(' '+cmd +': ' + str(not info_cmd) + ".\n\r\t")
|
||||||
else:
|
else:
|
||||||
if runSupport[curPlat][phone]:
|
if runSupport[curPlat][phone]:
|
||||||
print 'in desploy or run:', phone, getAndroidDevices()
|
print 'in desploy or run:', phone, getAndroidDevices()
|
||||||
if phone == 'android' and getAndroidDevices() == 0:
|
if phone == 'android' and getAndroidDevices() == 0:
|
||||||
strInfo = 'no android device, please checkout the device is running ok.'
|
strInfo = 'no android device, please checkout the device is running ok.'
|
||||||
print strInfo
|
print strInfo
|
||||||
else:
|
else:
|
||||||
if level == ENUM_PARAM.run:
|
if level == ENUM_PARAM.run:
|
||||||
global cur_test_name
|
global cur_test_name
|
||||||
cur_test_name = proj+','+phone
|
cur_test_name = proj+','+phone
|
||||||
thread_close = myThread('close')
|
thread_close = myThread('close')
|
||||||
thread_close.start()
|
thread_close.start()
|
||||||
info_cmd = os.system(cmd)
|
info_cmd = os.system(cmd)
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
appendToResult(' '+cmd +': ' + str(not info_cmd) + ".\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):
|
||||||
print 'will build and run, in function build_run'
|
print 'will build and run, in function build_run'
|
||||||
for level in LEVEL_COCOS:
|
for level in LEVEL_COCOS:
|
||||||
print 'level:', level, cocos_param, LEVEL_COCOS[level]
|
print 'level:', level, cocos_param, LEVEL_COCOS[level]
|
||||||
if cocos_param >= LEVEL_COCOS[level] and level > lv_ignore:
|
if cocos_param >= LEVEL_COCOS[level] and level > lv_ignore:
|
||||||
if level == ENUM_PARAM.new:
|
if level == ENUM_PARAM.new:
|
||||||
clean_project()
|
clean_project()
|
||||||
cocos_project(level)
|
cocos_project(level)
|
||||||
|
|
||||||
# android simulator name.
|
# android simulator name.
|
||||||
ANDROID_SIMULATOR_NAME = 'console-test'
|
ANDROID_SIMULATOR_NAME = 'console-test'
|
||||||
# start android simulator if no android devices connected.
|
# start android simulator if no android devices connected.
|
||||||
def start_android_simulator():
|
def start_android_simulator():
|
||||||
print 'in function start_android_simulator.'
|
print 'in function start_android_simulator.'
|
||||||
if getAndroidDevices() > 0:
|
if getAndroidDevices() > 0:
|
||||||
print 'already connected android device.'
|
print 'already connected android device.'
|
||||||
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={
|
||||||
0:'EMAIL_HOST',
|
0:'EMAIL_HOST',
|
||||||
1:'EMAIL_USER',
|
1:'EMAIL_USER',
|
||||||
2:'EMAIL_PWD',
|
2:'EMAIL_PWD',
|
||||||
3:'EMAIL_POSTFIX',
|
3:'EMAIL_POSTFIX',
|
||||||
4:'EMAIL_LIST',
|
4:'EMAIL_LIST',
|
||||||
5:'NEED_SEND_EMAIL'
|
5:'NEED_SEND_EMAIL'
|
||||||
}
|
}
|
||||||
|
|
||||||
OBJ_EMAIL_INFO = {}
|
OBJ_EMAIL_INFO = {}
|
||||||
print 'will get env info.'
|
print 'will get env info.'
|
||||||
for key in EMAIL_KEYS:
|
for key in EMAIL_KEYS:
|
||||||
if os.environ.has_key(EMAIL_KEYS[key]):
|
if os.environ.has_key(EMAIL_KEYS[key]):
|
||||||
OBJ_EMAIL_INFO[EMAIL_KEYS[key]] = os.environ[EMAIL_KEYS[key]]
|
OBJ_EMAIL_INFO[EMAIL_KEYS[key]] = os.environ[EMAIL_KEYS[key]]
|
||||||
if key == 4:
|
if key == 4:
|
||||||
# string to list by ' ', for separate users.
|
# string to list by ' ', for separate users.
|
||||||
OBJ_EMAIL_INFO[EMAIL_KEYS[4]] = OBJ_EMAIL_INFO[EMAIL_KEYS[4]].split(' ')
|
OBJ_EMAIL_INFO[EMAIL_KEYS[4]] = OBJ_EMAIL_INFO[EMAIL_KEYS[4]].split(' ')
|
||||||
|
|
||||||
print 'will send email.', OBJ_EMAIL_INFO
|
print 'will send email.', OBJ_EMAIL_INFO
|
||||||
def send_mail(to_list,sub,title,content):
|
def send_mail(to_list,sub,title,content):
|
||||||
mail_user = OBJ_EMAIL_INFO[ EMAIL_KEYS[1] ]
|
mail_user = OBJ_EMAIL_INFO[ EMAIL_KEYS[1] ]
|
||||||
mail_postfix = OBJ_EMAIL_INFO[ EMAIL_KEYS[3] ]
|
mail_postfix = OBJ_EMAIL_INFO[ EMAIL_KEYS[3] ]
|
||||||
mail_host = OBJ_EMAIL_INFO[ EMAIL_KEYS[0] ]
|
mail_host = OBJ_EMAIL_INFO[ EMAIL_KEYS[0] ]
|
||||||
mail_pass = OBJ_EMAIL_INFO[ EMAIL_KEYS[2] ]
|
mail_pass = OBJ_EMAIL_INFO[ EMAIL_KEYS[2] ]
|
||||||
me = mail_user+"<"+mail_user+"@"+mail_postfix+">"
|
me = mail_user+"<"+mail_user+"@"+mail_postfix+">"
|
||||||
msg = MIMEText(content,_subtype='plain',_charset='gb2312')
|
msg = MIMEText(content,_subtype='plain',_charset='gb2312')
|
||||||
msg['Subject'] = sub
|
msg['Subject'] = sub
|
||||||
msg['From'] = me
|
msg['From'] = me
|
||||||
msg['To'] = " ".join(to_list)
|
msg['To'] = " ".join(to_list)
|
||||||
print 'to users:', msg['To']
|
print 'to users:', msg['To']
|
||||||
msg['Content'] = 'test'
|
msg['Content'] = 'test'
|
||||||
try:
|
try:
|
||||||
s = smtplib.SMTP()
|
s = smtplib.SMTP()
|
||||||
s.connect(mail_host)
|
s.connect(mail_host)
|
||||||
s.login(mail_user,mail_pass)
|
s.login(mail_user,mail_pass)
|
||||||
s.sendmail(me, to_list, str(msg))
|
s.sendmail(me, to_list, str(msg))
|
||||||
print 'info:', me, to_list, str(msg)
|
print 'info:', me, to_list, str(msg)
|
||||||
s.close()
|
s.close()
|
||||||
appendToResult( 'send email true:' + str(msg) )
|
appendToResult( 'send email true:' + str(msg) )
|
||||||
return True
|
return True
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
appendToResult( 'send email false:' + str(e) )
|
appendToResult( 'send email false:' + str(e) )
|
||||||
print str(e)
|
print str(e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
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
|
# get package size
|
||||||
def getdirsize(dir):
|
def getdirsize(dir):
|
||||||
size = 0L
|
size = 0L
|
||||||
for root, dirs, files in os.walk(dir):
|
for root, dirs, files in os.walk(dir):
|
||||||
size += sum([getsize(join(root, name)) for name in files])
|
size += sum([getsize(join(root, name)) for name in files])
|
||||||
return size
|
return size
|
||||||
APP_FILE_DIR = {
|
APP_FILE_DIR = {
|
||||||
'cpp':'bin/debug/',
|
'cpp':'bin/debug/',
|
||||||
'lua':'runtime/'
|
'lua':'runtime/'
|
||||||
}
|
}
|
||||||
APP_FILE_SUFFIX = {
|
APP_FILE_SUFFIX = {
|
||||||
'mac':'.app',
|
'mac':'.app',
|
||||||
'ios':'.app',
|
'ios':'.app',
|
||||||
'android':'-debug-unaligned.apk'
|
'android':'-debug-unaligned.apk'
|
||||||
}
|
}
|
||||||
if os.environ.has_key('APP_FILE_SUFFIX'):
|
if os.environ.has_key('APP_FILE_SUFFIX'):
|
||||||
str_app_suffix = os.environ['APP_FILE_SUFFIX']
|
str_app_suffix = os.environ['APP_FILE_SUFFIX']
|
||||||
APP_FILE_SUFFIX = eval(str_app_suffix)
|
APP_FILE_SUFFIX = eval(str_app_suffix)
|
||||||
|
|
||||||
def getPackageSize():
|
def getPackageSize():
|
||||||
for proj in project_types:
|
for proj in project_types:
|
||||||
for phone in phonePlats:
|
for phone in phonePlats:
|
||||||
# if runSupport[curPlat][phone]:
|
# if runSupport[curPlat][phone]:
|
||||||
package_path = './'+proj+PROJ_SUFFIX+'/'+APP_FILE_DIR[proj]+phone+'/'+proj+PROJ_SUFFIX+APP_FILE_SUFFIX[phone]
|
package_path = './'+proj+PROJ_SUFFIX+'/'+APP_FILE_DIR[proj]+phone+'/'+proj+PROJ_SUFFIX+APP_FILE_SUFFIX[phone]
|
||||||
print 'package_path', package_path
|
print 'package_path', package_path
|
||||||
package_size = 0
|
package_size = 0
|
||||||
if os.path.isfile(package_path):
|
if os.path.isfile(package_path):
|
||||||
package_size = os.path.getsize(package_path);
|
package_size = os.path.getsize(package_path);
|
||||||
else:
|
else:
|
||||||
package_size = getdirsize(package_path);
|
package_size = getdirsize(package_path);
|
||||||
strSize = 'size of '+proj+PROJ_SUFFIX+' '+phone+' is:'+str(package_size/(1024))+'KB'+'\n\t'
|
strSize = 'size of '+proj+PROJ_SUFFIX+' '+phone+' is:'+str(package_size/(1024))+'KB'+'\n\t'
|
||||||
print 'strSize:', strSize
|
print 'strSize:', strSize
|
||||||
appendToResult(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 'ANY_ERROR_IN_RUN:', ANY_ERROR_IN_RUN
|
print 'ANY_ERROR_IN_RUN:', ANY_ERROR_IN_RUN
|
||||||
print 'end build run. and get package size.'
|
print 'end build run. and get package size.'
|
||||||
getPackageSize()
|
getPackageSize()
|
||||||
print 'will send email:'
|
print 'will send email:'
|
||||||
print 'console_result:', console_result
|
print 'console_result:', console_result
|
||||||
if OBJ_EMAIL_INFO[ EMAIL_KEYS[5] ] or ANY_ERROR_IN_RUN:
|
if OBJ_EMAIL_INFO[ EMAIL_KEYS[5] ] or ANY_ERROR_IN_RUN:
|
||||||
sendEmail(console_result)
|
sendEmail(console_result)
|
||||||
|
|
||||||
# -------------- main --------------
|
# -------------- main --------------
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
sys_ret = 0
|
sys_ret = 0
|
||||||
try:
|
try:
|
||||||
sys_ret = main()
|
sys_ret = main()
|
||||||
except:
|
except:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
sys_ret = 1
|
sys_ret = 1
|
||||||
finally:
|
finally:
|
||||||
sys.exit(sys_ret)
|
sys.exit(sys_ret)
|
||||||
|
|
|
@ -6,5 +6,5 @@ ret = os.system('python -u tools/jenkins-scripts/autotest.py')
|
||||||
os.system('git reset --hard')
|
os.system('git reset --hard')
|
||||||
print ret
|
print ret
|
||||||
if(ret > 0):
|
if(ret > 0):
|
||||||
ret = 1
|
ret = 1
|
||||||
exit(ret)
|
exit(ret)
|
||||||
|
|
|
@ -5,10 +5,10 @@ print ' Branch:develop'
|
||||||
print ' Target:Android'
|
print ' Target:Android'
|
||||||
print ' build script:python build/android-build.py all'
|
print ' build script:python build/android-build.py all'
|
||||||
if(os.path.exists('build/android-build.py') == False):
|
if(os.path.exists('build/android-build.py') == False):
|
||||||
node_name = os.environ['NODE_NAME']
|
node_name = os.environ['NODE_NAME']
|
||||||
source_dir = '../cocos-2dx-develop-base-repo/node/' + node_name + "/."
|
source_dir = '../cocos-2dx-develop-base-repo/node/' + node_name + "/."
|
||||||
os.system("cp -r" + source_dir + " .")
|
os.system("cp -r" + source_dir + " .")
|
||||||
os.system('git pull origin develop')
|
os.system('git pull origin develop')
|
||||||
|
|
||||||
os.system('git submodule update --init --force')
|
os.system('git submodule update --init --force')
|
||||||
ret = os.system('python build/android-build.py -n -j8 all')
|
ret = os.system('python build/android-build.py -n -j8 all')
|
||||||
|
@ -16,6 +16,6 @@ os.system('git clean -xdf -f')
|
||||||
print 'build exit'
|
print 'build exit'
|
||||||
print ret
|
print ret
|
||||||
if ret == 0:
|
if ret == 0:
|
||||||
exit(0)
|
exit(0)
|
||||||
else:
|
else:
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
|
@ -2,20 +2,20 @@ import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
def check_ret(ret):
|
def check_ret(ret):
|
||||||
if(ret != 0):
|
if(ret != 0):
|
||||||
os.system('git checkout -B develop remotes/origin/develop')
|
os.system('git checkout -B develop remotes/origin/develop')
|
||||||
os.system('git clean -xdf -f')
|
os.system('git clean -xdf -f')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
branchs = ['develop', 'master']
|
branchs = ['develop', 'master']
|
||||||
for item in branchs:
|
for item in branchs:
|
||||||
os.system('git clean -xdf -f')
|
os.system('git clean -xdf -f')
|
||||||
os.system('git checkout -B ' + item + ' remotes/origin/' + item)
|
os.system('git checkout -B ' + item + ' remotes/origin/' + item)
|
||||||
os.system('git clean -xdf -f')
|
os.system('git clean -xdf -f')
|
||||||
ret = os.system('git pull origin')
|
ret = os.system('git pull origin')
|
||||||
check_ret(ret)
|
check_ret(ret)
|
||||||
ret = os.system('git submodule update --init --force')
|
ret = os.system('git submodule update --init --force')
|
||||||
check_ret(ret)
|
check_ret(ret)
|
||||||
|
|
||||||
#back to develop
|
#back to develop
|
||||||
os.system('git checkout -B develop remotes/origin/develop')
|
os.system('git checkout -B develop remotes/origin/develop')
|
||||||
|
|
|
@ -4,10 +4,10 @@ print ' Host:MAC'
|
||||||
print ' Branch:develop'
|
print ' Branch:develop'
|
||||||
print ' Target:iOS'
|
print ' Target:iOS'
|
||||||
if(os.path.exists('tools/jenkins-scripts/ios-build.sh') == False):
|
if(os.path.exists('tools/jenkins-scripts/ios-build.sh') == False):
|
||||||
node_name = os.environ['NODE_NAME']
|
node_name = os.environ['NODE_NAME']
|
||||||
source_dir = '../cocos-2dx-develop-base-repo/node/' + node_name + "/."
|
source_dir = '../cocos-2dx-develop-base-repo/node/' + node_name + "/."
|
||||||
os.system("cp -r " + source_dir + " .")
|
os.system("cp -r " + source_dir + " .")
|
||||||
os.system('git pull origin develop')
|
os.system('git pull origin develop')
|
||||||
|
|
||||||
os.system('git submodule update --init --force')
|
os.system('git submodule update --init --force')
|
||||||
ret = os.system('tools/jenkins-scripts/ios-build.sh')
|
ret = os.system('tools/jenkins-scripts/ios-build.sh')
|
||||||
|
@ -15,6 +15,6 @@ os.system('git clean -xdf -f')
|
||||||
print 'build exit'
|
print 'build exit'
|
||||||
print ret
|
print ret
|
||||||
if ret == 0:
|
if ret == 0:
|
||||||
exit(0)
|
exit(0)
|
||||||
else:
|
else:
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
|
@ -7,11 +7,11 @@ print ' Branch:develop'
|
||||||
print ' Target:win32'
|
print ' Target:win32'
|
||||||
print ' "%VS110COMNTOOLS%..\IDE\devenv.com" "build\cocos2d-win32.vc2012.sln" /Build "Debug|Win32"'
|
print ' "%VS110COMNTOOLS%..\IDE\devenv.com" "build\cocos2d-win32.vc2012.sln" /Build "Debug|Win32"'
|
||||||
if(os.path.exists('build/cocos2d-win32.vc2012.sln') == False):
|
if(os.path.exists('build/cocos2d-win32.vc2012.sln') == False):
|
||||||
node_name = os.environ['NODE_NAME']
|
node_name = os.environ['NODE_NAME']
|
||||||
source_dir = '../cocos-2dx-develop-base-repo/node/' + node_name
|
source_dir = '../cocos-2dx-develop-base-repo/node/' + node_name
|
||||||
source_dir = source_dir.replace("/", os.sep)
|
source_dir = source_dir.replace("/", os.sep)
|
||||||
os.system("xcopy " + source_dir + " . /E /Y /H")
|
os.system("xcopy " + source_dir + " . /E /Y /H")
|
||||||
os.system('git pull origin develop')
|
os.system('git pull origin develop')
|
||||||
|
|
||||||
os.system('git submodule update --init --force')
|
os.system('git submodule update --init --force')
|
||||||
ret = subprocess.call('"%VS110COMNTOOLS%..\IDE\devenv.com" "build\cocos2d-win32.vc2012.sln" /Build "Debug|Win32"', shell=True)
|
ret = subprocess.call('"%VS110COMNTOOLS%..\IDE\devenv.com" "build\cocos2d-win32.vc2012.sln" /Build "Debug|Win32"', shell=True)
|
||||||
|
@ -19,6 +19,6 @@ os.system('git clean -xdf -f')
|
||||||
print 'build exit'
|
print 'build exit'
|
||||||
print ret
|
print ret
|
||||||
if ret == 0:
|
if ret == 0:
|
||||||
exit(0)
|
exit(0)
|
||||||
else:
|
else:
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
|
@ -5,11 +5,11 @@ print ' Branch:develop'
|
||||||
print ' Target:Doxygen'
|
print ' Target:Doxygen'
|
||||||
print ' doxygen doxygen.config'
|
print ' doxygen doxygen.config'
|
||||||
if(os.path.exists('docs/doxygen.config') == False):
|
if(os.path.exists('docs/doxygen.config') == False):
|
||||||
node_name = os.environ['NODE_NAME']
|
node_name = os.environ['NODE_NAME']
|
||||||
source_dir = '../cocos-2dx-develop-base-repo/node/' + node_name
|
source_dir = '../cocos-2dx-develop-base-repo/node/' + node_name
|
||||||
source_dir = source_dir.replace("/", os.sep)
|
source_dir = source_dir.replace("/", os.sep)
|
||||||
os.system("xcopy " + source_dir + " . /E /Y /H")
|
os.system("xcopy " + source_dir + " . /E /Y /H")
|
||||||
os.system('git pull origin develop')
|
os.system('git pull origin develop')
|
||||||
|
|
||||||
os.system('git submodule update --init --force')
|
os.system('git submodule update --init --force')
|
||||||
os.chdir('docs/')
|
os.chdir('docs/')
|
||||||
|
@ -19,6 +19,6 @@ os.system('git clean -xdf -f')
|
||||||
print 'build exit'
|
print 'build exit'
|
||||||
print ret
|
print ret
|
||||||
if ret == 0:
|
if ret == 0:
|
||||||
exit(0)
|
exit(0)
|
||||||
else:
|
else:
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
|
@ -3,6 +3,6 @@ import os
|
||||||
#os.system('git pull origin develop')
|
#os.system('git pull origin develop')
|
||||||
ret = os.system('python -u tools/jenkins-scripts/job-comment-trigger.py')
|
ret = os.system('python -u tools/jenkins-scripts/job-comment-trigger.py')
|
||||||
if ret == 0:
|
if ret == 0:
|
||||||
exit(0)
|
exit(0)
|
||||||
else:
|
else:
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
|
@ -3,6 +3,6 @@ import os
|
||||||
#os.system('git pull origin develop')
|
#os.system('git pull origin develop')
|
||||||
ret = os.system('python -u tools/jenkins-scripts/job-trigger.py')
|
ret = os.system('python -u tools/jenkins-scripts/job-trigger.py')
|
||||||
if ret == 0:
|
if ret == 0:
|
||||||
exit(0)
|
exit(0)
|
||||||
else:
|
else:
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
if(os.path.exists('tools/jenkins-scripts/pull-request-builder.py') == False):
|
if(os.path.exists('tools/jenkins-scripts/pull-request-builder.py') == False):
|
||||||
node_name = os.environ['NODE_NAME']
|
node_name = os.environ['NODE_NAME']
|
||||||
source_dir = '../../../cocos-2dx-develop-base-repo/node/' + node_name
|
source_dir = '../../../cocos-2dx-develop-base-repo/node/' + node_name
|
||||||
if(platform.system() == 'Windows'):
|
if(platform.system() == 'Windows'):
|
||||||
source_dir = source_dir.replace("/", os.sep)
|
source_dir = source_dir.replace("/", os.sep)
|
||||||
os.system("xcopy " + source_dir + ' . /E /Y /H')
|
os.system("xcopy " + source_dir + ' . /E /Y /H')
|
||||||
else:
|
else:
|
||||||
os.system("cp -r " + source_dir + "/. .")
|
os.system("cp -r " + source_dir + "/. .")
|
||||||
|
|
||||||
def clean_workspace():
|
def clean_workspace():
|
||||||
os.system('git reset --hard')
|
os.system('git reset --hard')
|
||||||
os.system('git clean -xdf -f')
|
os.system('git clean -xdf -f')
|
||||||
|
|
||||||
clean_workspace()
|
clean_workspace()
|
||||||
os.system('git checkout develop')
|
os.system('git checkout develop')
|
||||||
|
@ -19,14 +19,14 @@ clean_workspace()
|
||||||
os.system('git pull origin develop')
|
os.system('git pull origin develop')
|
||||||
|
|
||||||
for i in range(0, 3):
|
for i in range(0, 3):
|
||||||
ret = os.system('python -u tools/jenkins-scripts/pull-request-builder.py')
|
ret = os.system('python -u tools/jenkins-scripts/pull-request-builder.py')
|
||||||
if(ret > 255):
|
if(ret > 255):
|
||||||
ret >>= 8
|
ret >>= 8
|
||||||
if(ret == 0) or (ret == 1):
|
if(ret == 0) or (ret == 1):
|
||||||
break
|
break
|
||||||
|
|
||||||
clean_workspace()
|
clean_workspace()
|
||||||
print ret
|
print ret
|
||||||
if(ret > 0):
|
if(ret > 0):
|
||||||
ret = 1
|
ret = 1
|
||||||
exit(ret)
|
exit(ret)
|
||||||
|
|
|
@ -8,5 +8,5 @@ ret = os.system('python -u tools/jenkins-scripts/cocos-console-test.py')
|
||||||
os.system('git reset --hard')
|
os.system('git reset --hard')
|
||||||
print ret
|
print ret
|
||||||
if(ret > 0):
|
if(ret > 0):
|
||||||
ret = 1
|
ret = 1
|
||||||
exit(ret)
|
exit(ret)
|
||||||
|
|
|
@ -2,7 +2,7 @@ import os
|
||||||
import sys
|
import sys
|
||||||
ret = os.system('git pull origin master')
|
ret = os.system('git pull origin master')
|
||||||
if(ret != 0):
|
if(ret != 0):
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
ret = os.system('git submodule update --init --force')
|
ret = os.system('git submodule update --init --force')
|
||||||
if(ret != 0):
|
if(ret != 0):
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
if(os.path.exists('CocoStudio/CSX/CSX/CSX.pro') == False):
|
if(os.path.exists('CocoStudio/CSX/CSX/CSX.pro') == False):
|
||||||
node_name = os.environ['NODE_NAME']
|
node_name = os.environ['NODE_NAME']
|
||||||
source_dir = '../../../cocostudiox-base-repo/node/' + node_name
|
source_dir = '../../../cocostudiox-base-repo/node/' + node_name
|
||||||
if(platform.system() == 'Windows'):
|
if(platform.system() == 'Windows'):
|
||||||
source_dir = source_dir.replace("/", os.sep)
|
source_dir = source_dir.replace("/", os.sep)
|
||||||
os.system("xcopy " + source_dir + ' . /E /Y /H')
|
os.system("xcopy " + source_dir + ' . /E /Y /H')
|
||||||
else:
|
else:
|
||||||
os.system("cp -r " + source_dir + "/. .")
|
os.system("cp -r " + source_dir + "/. .")
|
||||||
|
|
||||||
os.system('git pull origin')
|
os.system('git pull origin')
|
||||||
os.system('git submodule update --init --force')
|
os.system('git submodule update --init --force')
|
||||||
|
@ -16,15 +16,15 @@ node_name = os.environ['NODE_NAME']
|
||||||
os.chdir('CocoStudio/CSX/CSX')
|
os.chdir('CocoStudio/CSX/CSX')
|
||||||
ret = os.system('qmake -r')
|
ret = os.system('qmake -r')
|
||||||
if(ret == 0):
|
if(ret == 0):
|
||||||
if(node_name == 'android_mac'):
|
if(node_name == 'android_mac'):
|
||||||
ret = os.system('make -j8')
|
ret = os.system('make -j8')
|
||||||
elif(node_name == 'win32_win7'):
|
elif(node_name == 'win32_win7'):
|
||||||
ret = os.system('mingw32-make -j8')
|
ret = os.system('mingw32-make -j8')
|
||||||
os.chdir('../../..')
|
os.chdir('../../..')
|
||||||
|
|
||||||
os.system('git clean -xdf')
|
os.system('git clean -xdf')
|
||||||
os.system('git reset --hard')
|
os.system('git reset --hard')
|
||||||
print ret
|
print ret
|
||||||
if(ret > 0):
|
if(ret > 0):
|
||||||
ret = 1
|
ret = 1
|
||||||
exit(ret)
|
exit(ret)
|
||||||
|
|
|
@ -19,290 +19,290 @@ import paramiko
|
||||||
payload = {}
|
payload = {}
|
||||||
#get payload from os env
|
#get payload from os env
|
||||||
if os.environ.has_key('payload'):
|
if os.environ.has_key('payload'):
|
||||||
payload_str = os.environ['payload']
|
payload_str = os.environ['payload']
|
||||||
#parse to json obj
|
#parse to json obj
|
||||||
payload = json.loads(payload_str)
|
payload = json.loads(payload_str)
|
||||||
print 'payload:',payload
|
print 'payload:',payload
|
||||||
pr_num = 6326
|
pr_num = 6326
|
||||||
#get pull number
|
#get pull number
|
||||||
if payload.has_key('number'):
|
if payload.has_key('number'):
|
||||||
pr_num = payload['number']
|
pr_num = payload['number']
|
||||||
print 'pr_num:' + str(pr_num)
|
print 'pr_num:' + str(pr_num)
|
||||||
run_app_time = 5
|
run_app_time = 5
|
||||||
if os.environ.has_key('RUN_APP_TIME'):
|
if os.environ.has_key('RUN_APP_TIME'):
|
||||||
run_app_time = os.environ['RUN_APP_TIME']
|
run_app_time = os.environ['RUN_APP_TIME']
|
||||||
print 'run_app_time:', run_app_time
|
print 'run_app_time:', run_app_time
|
||||||
|
|
||||||
test_name = ['cpp_empty_test']
|
test_name = ['cpp_empty_test']
|
||||||
if os.environ.has_key('TESTS_NAME'):
|
if os.environ.has_key('TESTS_NAME'):
|
||||||
temp_var = os.environ['TESTS_NAME']
|
temp_var = os.environ['TESTS_NAME']
|
||||||
test_name = temp_var.split(', ')
|
test_name = temp_var.split(', ')
|
||||||
package_name = ['org.cocos2dx.cpp_empty_test']
|
package_name = ['org.cocos2dx.cpp_empty_test']
|
||||||
if os.environ.has_key('PACKAGE_NAME'):
|
if os.environ.has_key('PACKAGE_NAME'):
|
||||||
temp_var = os.environ['PACKAGE_NAME']
|
temp_var = os.environ['PACKAGE_NAME']
|
||||||
package_name = temp_var.split(', ')
|
package_name = temp_var.split(', ')
|
||||||
activity_name = ['org.cocos2dx.cpp_empty_test.AppActivity']
|
activity_name = ['org.cocos2dx.cpp_empty_test.AppActivity']
|
||||||
if os.environ.has_key('ACTIVITY_NAME'):
|
if os.environ.has_key('ACTIVITY_NAME'):
|
||||||
temp_var = os.environ['ACTIVITY_NAME']
|
temp_var = os.environ['ACTIVITY_NAME']
|
||||||
activity_name = temp_var.split(', ')
|
activity_name = temp_var.split(', ')
|
||||||
gIdx = 0
|
gIdx = 0
|
||||||
if os.environ.has_key('TEST_INDEX'):
|
if os.environ.has_key('TEST_INDEX'):
|
||||||
gIdx = os.environ('TEST_INDEX')
|
gIdx = os.environ('TEST_INDEX')
|
||||||
|
|
||||||
current_platform = platform.system()
|
current_platform = platform.system()
|
||||||
print 'current platform is:', current_platform
|
print 'current platform is:', current_platform
|
||||||
|
|
||||||
arrDevices = []
|
arrDevices = []
|
||||||
def getDevices():
|
def getDevices():
|
||||||
cmd = 'adb devices'
|
cmd = 'adb devices'
|
||||||
info_devices = os.popen(cmd).read()
|
info_devices = os.popen(cmd).read()
|
||||||
arr_info = info_devices.split('\n')
|
arr_info = info_devices.split('\n')
|
||||||
del arr_info[0]
|
del arr_info[0]
|
||||||
count = 0
|
count = 0
|
||||||
for device in arr_info:
|
for device in arr_info:
|
||||||
if len(device) > 0:
|
if len(device) > 0:
|
||||||
count += 1
|
count += 1
|
||||||
print 'device ', count,device
|
print 'device ', count,device
|
||||||
deviceInfo = device.split(' ')
|
deviceInfo = device.split(' ')
|
||||||
global arrDevices
|
global arrDevices
|
||||||
obj = {}
|
obj = {}
|
||||||
obj['name'] = deviceInfo[0]
|
obj['name'] = deviceInfo[0]
|
||||||
arrDevices.append(obj)
|
arrDevices.append(obj)
|
||||||
return count
|
return count
|
||||||
|
|
||||||
def getADBDeviceIP(device_name):
|
def getADBDeviceIP(device_name):
|
||||||
output = os.popen("adb -s "+device_name+" shell netcfg")
|
output = os.popen("adb -s "+device_name+" shell netcfg")
|
||||||
configs = output.read().split('\r\n')
|
configs = output.read().split('\r\n')
|
||||||
output.close()
|
output.close()
|
||||||
for l in configs:
|
for l in configs:
|
||||||
items = l.split()
|
items = l.split()
|
||||||
if len(items)>1 and items[1] == 'UP':
|
if len(items)>1 and items[1] == 'UP':
|
||||||
if items[2].find('127.0.0.1') < 0 and items[2].find('0.0.0.0') < 0:
|
if items[2].find('127.0.0.1') < 0 and items[2].find('0.0.0.0') < 0:
|
||||||
return items[2]
|
return items[2]
|
||||||
return False
|
return False
|
||||||
def mapIP():
|
def mapIP():
|
||||||
for device in arrDevices:
|
for device in arrDevices:
|
||||||
ip_d = getADBDeviceIP(device['name'])
|
ip_d = getADBDeviceIP(device['name'])
|
||||||
device['ip'] = ip_d
|
device['ip'] = ip_d
|
||||||
|
|
||||||
allThreadIsRunning = {}
|
allThreadIsRunning = {}
|
||||||
def setThreadStatus():
|
def setThreadStatus():
|
||||||
for device in arrDevices:
|
for device in arrDevices:
|
||||||
allThreadIsRunning[device['name']] = 1
|
allThreadIsRunning[device['name']] = 1
|
||||||
|
|
||||||
devices_info = {}
|
devices_info = {}
|
||||||
info_list = '{"product":["model","brand","name","cpu.abi","cpu.abi2","manufacturer","locale.language","locale.region"],"build":["id","version.sdk","version.release"]}'
|
info_list = '{"product":["model","brand","name","cpu.abi","cpu.abi2","manufacturer","locale.language","locale.region"],"build":["id","version.sdk","version.release"]}'
|
||||||
if os.environ.has_key('DEVICE_INFO_LIST'):
|
if os.environ.has_key('DEVICE_INFO_LIST'):
|
||||||
info_list = os.environ['DEVICE_INFO_LIST']
|
info_list = os.environ['DEVICE_INFO_LIST']
|
||||||
info_list = eval(info_list)
|
info_list = eval(info_list)
|
||||||
def getDeviceInfoByName(name):
|
def getDeviceInfoByName(name):
|
||||||
cmd = ''
|
cmd = ''
|
||||||
dev_name = name
|
dev_name = name
|
||||||
if len(name) > 0:
|
if len(name) > 0:
|
||||||
cmd = 'adb -s '+name+' shell cat /system/build.prop'
|
cmd = 'adb -s '+name+' shell cat /system/build.prop'
|
||||||
else:
|
else:
|
||||||
cmd = 'adb shell cat /system/build.prop'
|
cmd = 'adb shell cat /system/build.prop'
|
||||||
dev_name = 'device one'
|
dev_name = 'device one'
|
||||||
pip_cat = os.popen(cmd)
|
pip_cat = os.popen(cmd)
|
||||||
read_info = pip_cat.read()
|
read_info = pip_cat.read()
|
||||||
read_info_list = read_info.split('\r\n')
|
read_info_list = read_info.split('\r\n')
|
||||||
device_info_one = {}
|
device_info_one = {}
|
||||||
def checkProperty(item_str, device_name):
|
def checkProperty(item_str, device_name):
|
||||||
for argv in info_list:
|
for argv in info_list:
|
||||||
for item in info_list[argv]:
|
for item in info_list[argv]:
|
||||||
prop = argv+'.'+item
|
prop = argv+'.'+item
|
||||||
if item_str.find(prop) > -1:
|
if item_str.find(prop) > -1:
|
||||||
arr_item = item_str.split('=')
|
arr_item = item_str.split('=')
|
||||||
device_info_one[prop] = arr_item[1]
|
device_info_one[prop] = arr_item[1]
|
||||||
break
|
break
|
||||||
for item in read_info_list:
|
for item in read_info_list:
|
||||||
checkProperty(item, dev_name)
|
checkProperty(item, dev_name)
|
||||||
devices_info[dev_name] = device_info_one
|
devices_info[dev_name] = device_info_one
|
||||||
|
|
||||||
#getDeviceInfoByName('')
|
#getDeviceInfoByName('')
|
||||||
#print 'device_info:',device_info
|
#print 'device_info:',device_info
|
||||||
def getDeviceInfomation():
|
def getDeviceInfomation():
|
||||||
for device in arrDevices:
|
for device in arrDevices:
|
||||||
getDeviceInfoByName(device['name'])
|
getDeviceInfoByName(device['name'])
|
||||||
|
|
||||||
info_empty_test = {}
|
info_empty_test = {}
|
||||||
info_empty_test_pro = ['install','open','socket','uninstall']
|
info_empty_test_pro = ['install','open','socket','uninstall']
|
||||||
def init_info_empty_test():
|
def init_info_empty_test():
|
||||||
for item in info_empty_test_pro:
|
for item in info_empty_test_pro:
|
||||||
info_empty_test[item] = {}
|
info_empty_test[item] = {}
|
||||||
init_info_empty_test()
|
init_info_empty_test()
|
||||||
|
|
||||||
apk_name = 'apks/'+test_name[gIdx]+'/'+test_name[gIdx]+'_'+str(pr_num)+'.apk'
|
apk_name = 'apks/'+test_name[gIdx]+'/'+test_name[gIdx]+'_'+str(pr_num)+'.apk'
|
||||||
def install_apk_on_device(device):
|
def install_apk_on_device(device):
|
||||||
name = device['name']
|
name = device['name']
|
||||||
cmd = 'adb -s '+name+' install '+apk_name
|
cmd = 'adb -s '+name+' install '+apk_name
|
||||||
print 'install on '+name
|
print 'install on '+name
|
||||||
info_install = os.popen(cmd).read()
|
info_install = os.popen(cmd).read()
|
||||||
print 'infomation of install apk:', info_install
|
print 'infomation of install apk:', info_install
|
||||||
info_install_arr = info_install.split('\r\n')
|
info_install_arr = info_install.split('\r\n')
|
||||||
info_install_result = False
|
info_install_result = False
|
||||||
for item in info_install_arr:
|
for item in info_install_arr:
|
||||||
if item.find('Success') > -1:
|
if item.find('Success') > -1:
|
||||||
info_install_result = True
|
info_install_result = True
|
||||||
info_empty_test['install'][name] = info_install_result
|
info_empty_test['install'][name] = info_install_result
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def open_apk_on_device(device):
|
def open_apk_on_device(device):
|
||||||
print 'will open activity:'
|
print 'will open activity:'
|
||||||
name = device['name']
|
name = device['name']
|
||||||
cmd = 'adb -s '+name+' shell am start -n '+package_name[gIdx]+'/'+activity_name[gIdx]
|
cmd = 'adb -s '+name+' shell am start -n '+package_name[gIdx]+'/'+activity_name[gIdx]
|
||||||
# print 'start activity:', cmd
|
# print 'start activity:', cmd
|
||||||
info_start = os.popen(cmd).read()
|
info_start = os.popen(cmd).read()
|
||||||
info_start = info_start.split('\r\n')
|
info_start = info_start.split('\r\n')
|
||||||
# print 'info_start:', info_start
|
# print 'info_start:', info_start
|
||||||
info_start_result = True
|
info_start_result = True
|
||||||
for info in info_start:
|
for info in info_start:
|
||||||
if info.find('Error:') > -1:
|
if info.find('Error:') > -1:
|
||||||
print 'infomation of open activity:',info
|
print 'infomation of open activity:',info
|
||||||
info_start_result = False
|
info_start_result = False
|
||||||
info_empty_test['open'][name] = info_start_result
|
info_empty_test['open'][name] = info_start_result
|
||||||
return True
|
return True
|
||||||
|
|
||||||
PORT = 5678
|
PORT = 5678
|
||||||
def socket_status_on_device(device):
|
def socket_status_on_device(device):
|
||||||
name = device['name']
|
name = device['name']
|
||||||
ip = device['ip']
|
ip = device['ip']
|
||||||
soc = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
|
soc = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
|
||||||
status_socket = False
|
status_socket = False
|
||||||
info_of_socket_result = ''
|
info_of_socket_result = ''
|
||||||
try:
|
try:
|
||||||
print 'telnet ', ip, PORT
|
print 'telnet ', ip, PORT
|
||||||
soc.connect((ip, PORT))
|
soc.connect((ip, PORT))
|
||||||
cmd = 'resolution\r\n'
|
cmd = 'resolution\r\n'
|
||||||
print 'connected successfully.'
|
print 'connected successfully.'
|
||||||
print 'send console command: resolution'
|
print 'send console command: resolution'
|
||||||
soc.send(cmd)
|
soc.send(cmd)
|
||||||
while True:
|
while True:
|
||||||
data = soc.recv(1024)
|
data = soc.recv(1024)
|
||||||
if len(data):
|
if len(data):
|
||||||
print data
|
print data
|
||||||
if data.find('size:') > -1:
|
if data.find('size:') > -1:
|
||||||
info_of_socket_result = 'OK'
|
info_of_socket_result = 'OK'
|
||||||
print 'close', test_name[gIdx]
|
print 'close', test_name[gIdx]
|
||||||
soc.send('director end')
|
soc.send('director end')
|
||||||
status_socket = True
|
status_socket = True
|
||||||
break
|
break
|
||||||
if not data:
|
if not data:
|
||||||
info_of_socket_result = test_name[gIdx]+' is crashed!'
|
info_of_socket_result = test_name[gIdx]+' is crashed!'
|
||||||
break
|
break
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
info_of_socket_result = test_name[gIdx]+' is crashed!'
|
info_of_socket_result = test_name[gIdx]+' is crashed!'
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
soc.close()
|
soc.close()
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
info_empty_test['socket'][name] = info_of_socket_result
|
info_empty_test['socket'][name] = info_of_socket_result
|
||||||
return status_socket
|
return status_socket
|
||||||
|
|
||||||
def uninstall_apk_on_device(device):
|
def uninstall_apk_on_device(device):
|
||||||
# adb shell pm uninstall -n org.cocos2dx.hellolua
|
# adb shell pm uninstall -n org.cocos2dx.hellolua
|
||||||
print 'uninstall ', test_name[gIdx]
|
print 'uninstall ', test_name[gIdx]
|
||||||
name = device['name']
|
name = device['name']
|
||||||
cmd = 'adb -s '+name+' shell pm uninstall -n '+package_name[gIdx]
|
cmd = 'adb -s '+name+' shell pm uninstall -n '+package_name[gIdx]
|
||||||
info_uninstall = os.popen(cmd).read()
|
info_uninstall = os.popen(cmd).read()
|
||||||
info_uninstall_result = ''
|
info_uninstall_result = ''
|
||||||
if info_uninstall.find('Success') > -1:
|
if info_uninstall.find('Success') > -1:
|
||||||
info_uninstall_result = 'OK'
|
info_uninstall_result = 'OK'
|
||||||
else:
|
else:
|
||||||
info_uninstall_result = 'uninstall Failed!'
|
info_uninstall_result = 'uninstall Failed!'
|
||||||
info_empty_test['uninstall'][name] = info_uninstall_result
|
info_empty_test['uninstall'][name] = info_uninstall_result
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def excute_test_on_device(device):
|
def excute_test_on_device(device):
|
||||||
uninstall_apk_on_device(device)
|
uninstall_apk_on_device(device)
|
||||||
print device
|
print device
|
||||||
info_install = install_apk_on_device(device)
|
info_install = install_apk_on_device(device)
|
||||||
print 'install:', info_install
|
print 'install:', info_install
|
||||||
info_open = open_apk_on_device(device)
|
info_open = open_apk_on_device(device)
|
||||||
print 'open:', info_open
|
print 'open:', info_open
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
info_socket = socket_status_on_device(device)
|
info_socket = socket_status_on_device(device)
|
||||||
print 'socket:', info_socket
|
print 'socket:', info_socket
|
||||||
info_uninstall = uninstall_apk_on_device(device)
|
info_uninstall = uninstall_apk_on_device(device)
|
||||||
print 'uninstall:', info_uninstall
|
print 'uninstall:', info_uninstall
|
||||||
allThreadIsRunning[device['name']] = 0
|
allThreadIsRunning[device['name']] = 0
|
||||||
|
|
||||||
address_of_result_html = ''
|
address_of_result_html = ''
|
||||||
def send_result_to_master():
|
def send_result_to_master():
|
||||||
if not os.environ.has_key('REMOTE_IP'):
|
if not os.environ.has_key('REMOTE_IP'):
|
||||||
return false
|
return false
|
||||||
remote_ip = os.environ['REMOTE_IP']
|
remote_ip = os.environ['REMOTE_IP']
|
||||||
remote_port = os.environ['REMOTE_PORT']
|
remote_port = os.environ['REMOTE_PORT']
|
||||||
remote_user = os.environ['REMOTE_USER']
|
remote_user = os.environ['REMOTE_USER']
|
||||||
remote_pwd = os.environ['REMOTE_PWD']
|
remote_pwd = os.environ['REMOTE_PWD']
|
||||||
remote_dir = os.environ['REMOTE_DIR']
|
remote_dir = os.environ['REMOTE_DIR']
|
||||||
remote_dir = remote_dir + str(pr_num)+'/'
|
remote_dir = remote_dir + str(pr_num)+'/'
|
||||||
print remote_dir
|
print remote_dir
|
||||||
ssh = paramiko.SSHClient()
|
ssh = paramiko.SSHClient()
|
||||||
print 'ssh:',ssh
|
print 'ssh:',ssh
|
||||||
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||||
ssh.connect(remote_ip, int(remote_port), remote_user, remote_pwd)
|
ssh.connect(remote_ip, int(remote_port), remote_user, remote_pwd)
|
||||||
# create dir
|
# create dir
|
||||||
stdin, stdout, stderr = ssh.exec_command("mkdir "+remote_dir)
|
stdin, stdout, stderr = ssh.exec_command("mkdir "+remote_dir)
|
||||||
ssh.close()
|
ssh.close()
|
||||||
trans = paramiko.Transport((remote_ip,int(remote_port)))
|
trans = paramiko.Transport((remote_ip,int(remote_port)))
|
||||||
trans.connect(username = remote_user, password = remote_pwd)
|
trans.connect(username = remote_user, password = remote_pwd)
|
||||||
sftp = paramiko.SFTPClient.from_transport(trans)
|
sftp = paramiko.SFTPClient.from_transport(trans)
|
||||||
remotepath = remote_dir+test_name[gIdx]+'_'+str(pr_num)+'.html'
|
remotepath = remote_dir+test_name[gIdx]+'_'+str(pr_num)+'.html'
|
||||||
localpath = 'html/cpp_empty_test/cpp_empty_test_'+str(pr_num)+'.html'
|
localpath = 'html/cpp_empty_test/cpp_empty_test_'+str(pr_num)+'.html'
|
||||||
sftp.put(localpath, remotepath)
|
sftp.put(localpath, remotepath)
|
||||||
sftp.close()
|
sftp.close()
|
||||||
result_dir = remote_dir.replace('/data',':9000')
|
result_dir = remote_dir.replace('/data',':9000')
|
||||||
global address_of_result_html
|
global address_of_result_html
|
||||||
address_of_result_html = 'http://'+remote_ip+result_dir+test_name[gIdx]+'_'+str(pr_num)+'.html'
|
address_of_result_html = 'http://'+remote_ip+result_dir+test_name[gIdx]+'_'+str(pr_num)+'.html'
|
||||||
|
|
||||||
def check_thread_is_running():
|
def check_thread_is_running():
|
||||||
while 1:
|
while 1:
|
||||||
in_running = 0
|
in_running = 0
|
||||||
for key in allThreadIsRunning:
|
for key in allThreadIsRunning:
|
||||||
in_running = in_running + allThreadIsRunning[key]
|
in_running = in_running + allThreadIsRunning[key]
|
||||||
# print 'in_running:', in_running
|
# print 'in_running:', in_running
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
if not in_running:
|
if not in_running:
|
||||||
break
|
break
|
||||||
print 'all cpp emptytest is finished.'
|
print 'all cpp emptytest is finished.'
|
||||||
log_emptytest_result()
|
log_emptytest_result()
|
||||||
print 'will send result:'
|
print 'will send result:'
|
||||||
send_result_to_master()
|
send_result_to_master()
|
||||||
print 'end of check thread is running.'
|
print 'end of check thread is running.'
|
||||||
print 'address of result is:',address_of_result_html
|
print 'address of result is:',address_of_result_html
|
||||||
|
|
||||||
def generate_html_with_result(result):
|
def generate_html_with_result(result):
|
||||||
target_path = 'html/cpp_empty_test/cpp_empty_test_'+str(pr_num)+'.html'
|
target_path = 'html/cpp_empty_test/cpp_empty_test_'+str(pr_num)+'.html'
|
||||||
data = codecs.open('hello.html', encoding='UTF-8').read()
|
data = codecs.open('hello.html', encoding='UTF-8').read()
|
||||||
data = re.sub("content", result, data)
|
data = re.sub("content", result, data)
|
||||||
codecs.open(target_path, 'wb', encoding='UTF-8').write(data)
|
codecs.open(target_path, 'wb', encoding='UTF-8').write(data)
|
||||||
|
|
||||||
empty_test_result = True
|
empty_test_result = True
|
||||||
str_result = ''
|
str_result = ''
|
||||||
def log_emptytest_result():
|
def log_emptytest_result():
|
||||||
def appendToResult(one_str):
|
def appendToResult(one_str):
|
||||||
global str_result
|
global str_result
|
||||||
str_result = str_result + one_str + '\r\n'
|
str_result = str_result + one_str + '\r\n'
|
||||||
appendToResult('<pre>')
|
appendToResult('<pre>')
|
||||||
appendToResult('empty test start:')
|
appendToResult('empty test start:')
|
||||||
for device in arrDevices:
|
for device in arrDevices:
|
||||||
name = device['name']
|
name = device['name']
|
||||||
appendToResult('device infomation of : '+name)
|
appendToResult('device infomation of : '+name)
|
||||||
for key in devices_info[name]:
|
for key in devices_info[name]:
|
||||||
appendToResult('\t'+key+':'+devices_info[name][key])
|
appendToResult('\t'+key+':'+devices_info[name][key])
|
||||||
appendToResult('install: ' + str(info_empty_test['install'][name]))
|
appendToResult('install: ' + str(info_empty_test['install'][name]))
|
||||||
appendToResult('open: ' + str(info_empty_test['open'][name]))
|
appendToResult('open: ' + str(info_empty_test['open'][name]))
|
||||||
appendToResult('telnet ' + str(device['ip'])+' : ' + str(info_empty_test['socket'][name]))
|
appendToResult('telnet ' + str(device['ip'])+' : ' + str(info_empty_test['socket'][name]))
|
||||||
appendToResult('close: ' + str(info_empty_test['socket'][name]))
|
appendToResult('close: ' + str(info_empty_test['socket'][name]))
|
||||||
appendToResult('uninstall: ' + str(info_empty_test['uninstall'][name]))
|
appendToResult('uninstall: ' + str(info_empty_test['uninstall'][name]))
|
||||||
if not info_empty_test['install'][name] or not info_empty_test['open'][name] or not info_empty_test['socket'][name] or not info_empty_test['uninstall'][name]:
|
if not info_empty_test['install'][name] or not info_empty_test['open'][name] or not info_empty_test['socket'][name] or not info_empty_test['uninstall'][name]:
|
||||||
empty_test_result = False
|
empty_test_result = False
|
||||||
appendToResult('run failed!')
|
appendToResult('run failed!')
|
||||||
else: appendToResult('run successfully!')
|
else: appendToResult('run successfully!')
|
||||||
appendToResult('')
|
appendToResult('')
|
||||||
appendToResult('empty test end.</pre>')
|
appendToResult('empty test end.</pre>')
|
||||||
generate_html_with_result(str_result)
|
generate_html_with_result(str_result)
|
||||||
print 'log empty test end'
|
print 'log empty test end'
|
||||||
|
|
||||||
class myThread(threading.Thread):
|
class myThread(threading.Thread):
|
||||||
def __init__(self,threadname):
|
def __init__(self,threadname):
|
||||||
|
@ -316,39 +316,39 @@ class myThread(threading.Thread):
|
||||||
excute_test_on_device(device)
|
excute_test_on_device(device)
|
||||||
|
|
||||||
def run_emptytest():
|
def run_emptytest():
|
||||||
for device in arrDevices:
|
for device in arrDevices:
|
||||||
th = myThread(device)
|
th = myThread(device)
|
||||||
th.start()
|
th.start()
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
print 'in main:'
|
print 'in main:'
|
||||||
getDevices()
|
getDevices()
|
||||||
if len(arrDevices):
|
if len(arrDevices):
|
||||||
mapIP()
|
mapIP()
|
||||||
setThreadStatus()
|
setThreadStatus()
|
||||||
print 'arrDevices:',arrDevices
|
print 'arrDevices:',arrDevices
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
else:
|
else:
|
||||||
print 'there is no device for emptytest, please check devices!'
|
print 'there is no device for emptytest, please check devices!'
|
||||||
return 1
|
return 1
|
||||||
if len(arrDevices):
|
if len(arrDevices):
|
||||||
getDeviceInfomation()
|
getDeviceInfomation()
|
||||||
run_emptytest()
|
run_emptytest()
|
||||||
check_thread_is_running()
|
check_thread_is_running()
|
||||||
print 'info_empty_test:', info_empty_test
|
print 'info_empty_test:', info_empty_test
|
||||||
print 'empty test end', empty_test_result
|
print 'empty test end', empty_test_result
|
||||||
if empty_test_result:
|
if empty_test_result:
|
||||||
return 0
|
return 0
|
||||||
else:
|
else:
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
# -------------- main --------------
|
# -------------- main --------------
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
sys_ret = 0
|
sys_ret = 0
|
||||||
try:
|
try:
|
||||||
sys_ret = main()
|
sys_ret = main()
|
||||||
except:
|
except:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
sys_ret = 1
|
sys_ret = 1
|
||||||
finally:
|
finally:
|
||||||
sys.exit(sys_ret)
|
sys.exit(sys_ret)
|
||||||
|
|
|
@ -12,61 +12,61 @@ job_trigger_url=os.environ['JOB_PULL_REQUEST_BUILD_TRIGGER_URL']
|
||||||
access_token = os.environ['GITHUB_ACCESS_TOKEN']
|
access_token = os.environ['GITHUB_ACCESS_TOKEN']
|
||||||
Headers = {"Authorization":"token " + access_token}
|
Headers = {"Authorization":"token " + access_token}
|
||||||
def main():
|
def main():
|
||||||
r = requests.get(url,headers=Headers)
|
r = requests.get(url,headers=Headers)
|
||||||
payload = r.json()
|
payload = r.json()
|
||||||
#print payload
|
#print payload
|
||||||
for pr in payload:
|
for pr in payload:
|
||||||
pr_num = pr['number']
|
pr_num = pr['number']
|
||||||
r = requests.get(pr['url']+"/commits",headers=Headers)
|
r = requests.get(pr['url']+"/commits",headers=Headers)
|
||||||
commits = r.json()
|
commits = r.json()
|
||||||
#print commits
|
#print commits
|
||||||
last_commit = commits[len(commits)-1]
|
last_commit = commits[len(commits)-1]
|
||||||
message = last_commit['commit']['message']
|
message = last_commit['commit']['message']
|
||||||
|
|
||||||
#print message
|
#print message
|
||||||
pattern = re.compile("\[ci(\s+)skip\]", re.I)
|
pattern = re.compile("\[ci(\s+)skip\]", re.I)
|
||||||
result_commit_title = pattern.search(message)
|
result_commit_title = pattern.search(message)
|
||||||
|
|
||||||
title = pr['title']
|
title = pr['title']
|
||||||
result_pr_title = pattern.search(title)
|
result_pr_title = pattern.search(title)
|
||||||
if result_commit_title is not None or result_pr_title is not None:
|
if result_commit_title is not None or result_pr_title is not None:
|
||||||
print 'skip build for pull request #' + str(pr_num)
|
print 'skip build for pull request #' + str(pr_num)
|
||||||
break
|
break
|
||||||
#return(0)
|
#return(0)
|
||||||
s = pr['statuses_url']
|
s = pr['statuses_url']
|
||||||
update_time = pr['updated_at']
|
update_time = pr['updated_at']
|
||||||
#print pr_num
|
#print pr_num
|
||||||
#print s
|
#print s
|
||||||
#print update_time
|
#print update_time
|
||||||
t = datetime.datetime.strptime(update_time, "%Y-%m-%dT%H:%M:%SZ")
|
t = datetime.datetime.strptime(update_time, "%Y-%m-%dT%H:%M:%SZ")
|
||||||
now = datetime.datetime.utcnow()
|
now = datetime.datetime.utcnow()
|
||||||
three_minutes = datetime.timedelta(seconds=3*60)
|
three_minutes = datetime.timedelta(seconds=3*60)
|
||||||
if (t + three_minutes < now):
|
if (t + three_minutes < now):
|
||||||
#print pr_num
|
#print pr_num
|
||||||
statuses = requests.get(s, headers=Headers)
|
statuses = requests.get(s, headers=Headers)
|
||||||
#print statuses.json()
|
#print statuses.json()
|
||||||
if(len(statuses.json()) < 1):
|
if(len(statuses.json()) < 1):
|
||||||
print pr_num
|
print pr_num
|
||||||
payload_forward = {}
|
payload_forward = {}
|
||||||
payload_forward['number']=pr_num
|
payload_forward['number']=pr_num
|
||||||
payload_forward['action']=pr['state']
|
payload_forward['action']=pr['state']
|
||||||
payload_forward['html_url']=pr['html_url']
|
payload_forward['html_url']=pr['html_url']
|
||||||
payload_forward['statuses_url']=pr['statuses_url']
|
payload_forward['statuses_url']=pr['statuses_url']
|
||||||
payload_forward['branch']=pr['base']['ref']
|
payload_forward['branch']=pr['base']['ref']
|
||||||
print payload_forward
|
print payload_forward
|
||||||
post_data = {'payload':""}
|
post_data = {'payload':""}
|
||||||
post_data['payload']= json.dumps(payload_forward)
|
post_data['payload']= json.dumps(payload_forward)
|
||||||
|
|
||||||
requests.post(job_trigger_url, data=post_data)
|
requests.post(job_trigger_url, data=post_data)
|
||||||
|
|
||||||
# -------------- main --------------
|
# -------------- main --------------
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
sys_ret = 0
|
sys_ret = 0
|
||||||
try:
|
try:
|
||||||
main()
|
main()
|
||||||
except:
|
except:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
sys_ret = 1
|
sys_ret = 1
|
||||||
finally:
|
finally:
|
||||||
sys.exit(sys_ret)
|
sys.exit(sys_ret)
|
||||||
|
|
||||||
|
|
|
@ -33,10 +33,10 @@ def send_mail(sub,title,content):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def sendEmail(pr, html_url, target_url):
|
def sendEmail(pr, html_url, target_url):
|
||||||
sub = "Pull request #" + str(pr) + " build is failed!"
|
sub = "Pull request #" + str(pr) + " build is failed!"
|
||||||
title = "build failed!"
|
title = "build failed!"
|
||||||
content = 'to view build result, check:\r\n'+target_url + '\r\nYou can view the failed pr at:\r\n'+html_url
|
content = 'to view build result, check:\r\n'+target_url + '\r\nYou can view the failed pr at:\r\n'+html_url
|
||||||
send_mail(sub, title, content)
|
send_mail(sub, title, content)
|
||||||
|
|
||||||
payload_str = os.environ['payload']
|
payload_str = os.environ['payload']
|
||||||
payload_str = payload_str.decode('utf-8','ignore')
|
payload_str = payload_str.decode('utf-8','ignore')
|
||||||
|
|
|
@ -25,40 +25,40 @@ print 'remote_port',int(remote_port[0])
|
||||||
|
|
||||||
all_machines = {}
|
all_machines = {}
|
||||||
def set_default_value_to_all_machines():
|
def set_default_value_to_all_machines():
|
||||||
for idx, item in enumerate(remote_machines):
|
for idx, item in enumerate(remote_machines):
|
||||||
all_machines[item]={}
|
all_machines[item]={}
|
||||||
all_machines[item]['ip']=remote_ip[idx]
|
all_machines[item]['ip']=remote_ip[idx]
|
||||||
all_machines[item]['dir']=remote_dir[idx]
|
all_machines[item]['dir']=remote_dir[idx]
|
||||||
all_machines[item]['port']=remote_port[idx]
|
all_machines[item]['port']=remote_port[idx]
|
||||||
all_machines[item]['user']=remote_user[idx]
|
all_machines[item]['user']=remote_user[idx]
|
||||||
all_machines[item]['pwd']=os.environ[item+'_PWD']
|
all_machines[item]['pwd']=os.environ[item+'_PWD']
|
||||||
|
|
||||||
def reboot_machine(machine, item):
|
def reboot_machine(machine, item):
|
||||||
print 'machine:',machine, 'item:', item
|
print 'machine:',machine, 'item:', item
|
||||||
remote_ip = machine['ip']
|
remote_ip = machine['ip']
|
||||||
remote_port = machine['port']
|
remote_port = machine['port']
|
||||||
remote_user = machine['user']
|
remote_user = machine['user']
|
||||||
remote_pwd = machine['pwd']
|
remote_pwd = machine['pwd']
|
||||||
remote_dir = os.path.join(machine['dir'],'workspace','reboot', 'reboot.py')
|
remote_dir = os.path.join(machine['dir'],'workspace','reboot', 'reboot.py')
|
||||||
print remote_dir
|
print remote_dir
|
||||||
ssh = paramiko.SSHClient()
|
ssh = paramiko.SSHClient()
|
||||||
print 'ssh:',ssh
|
print 'ssh:',ssh
|
||||||
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||||
ssh.connect(remote_ip, int(remote_port), remote_user, remote_pwd)
|
ssh.connect(remote_ip, int(remote_port), remote_user, remote_pwd)
|
||||||
# excute reboot.py on machine
|
# excute reboot.py on machine
|
||||||
cmd = 'python '+remote_dir
|
cmd = 'python '+remote_dir
|
||||||
if item == 'win32_win7':
|
if item == 'win32_win7':
|
||||||
cmd = 'cmd.exe /c "python '+remote_dir+'"'
|
cmd = 'cmd.exe /c "python '+remote_dir+'"'
|
||||||
stdin, stdout, stderr = ssh.exec_command(cmd)
|
stdin, stdout, stderr = ssh.exec_command(cmd)
|
||||||
print stdout.readlines()
|
print stdout.readlines()
|
||||||
ssh.close()
|
ssh.close()
|
||||||
print 'OK'
|
print 'OK'
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
print 'in main'
|
print 'in main'
|
||||||
set_default_value_to_all_machines()
|
set_default_value_to_all_machines()
|
||||||
for item in all_machines:
|
for item in all_machines:
|
||||||
reboot_machine( all_machines[item], item )
|
reboot_machine( all_machines[item], item )
|
||||||
|
|
||||||
# -------------- main --------------
|
# -------------- main --------------
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Reference in New Issue