You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

226 lines
7.3 KiB

import sys
import config
import time
import os
import subprocess
def MkWorkPath():
f = open("output/time.txt",'a')
f.write(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + "mk_workpath start !\n")
f.close
cmd = config.ssh + " -i "+config.key_pri+" -l "+config.User+" "+config.Ip
cmd = cmd + " mkdir -p "+config.RemoteWorkPath
p = subprocess.Popen(cmd)
while p.poll() is None:
time.sleep(0.5)
res = p.returncode
print(res)
if res != 0 :
f = open("output/time.txt",'a')
f.write(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + "[Error]" + "mk_workpath fail !\n")
f.close
else:
f = open("output/time.txt",'a')
f.write(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + "mk_workpath over!\n")
f.close
return res
def copy():
f = open("output/time.txt",'a')
f.write(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + "copy start!\n")
f.close
cmd = config.rsync + " -e '"+config.ssh+" -i "+config.key_pri+"' -chavzP --stats -r --delete --exclude={"+config.ExcludePath+"} --chmod=Du+rwx,Dgo+rwx,Fu+rwx,Fgo+rwx "
cmd = cmd + config.LocalPath+" "+config.User+"@"+config.Ip+":"+config.RemotePath
p = subprocess.Popen(cmd)
while p.poll() is None:
time.sleep(0.5)
res = p.returncode
if res != 0 :
f = open("output/time.txt",'a')
f.write(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + "[Error]" + "copy client/* fail!\n")
f.close
else:
f = open("output/time.txt",'a')
f.write(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + "copy client/* over\n")
f.close
return res
def dos2unix():
f = open("output/time.txt",'a')
f.write(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + "dos2unix start!\n")
f.close
cmd = config.ssh + " -i "+config.key_pri+" -l "+config.User+" "+config.Ip+" "
cmd = cmd + "cd "+config.RemotePath+";"
cmd = cmd + "cd build/build-ios-remote;"
cmd = cmd + "rm -f dos2unix.sh;"
cmd = cmd + "tar -xzvf dos2unix.sh.tar.gz;"
cmd = cmd + "bash dos2unix.sh;"
p = subprocess.Popen(cmd)
while p.poll() is None:
time.sleep(0.5)
res = p.returncode
if res != 0:
f = open("output/time.txt",'a')
f.write(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + "[Error]" + "dos2unix fail!\n")
f.close
else:
f = open("output/time.txt",'a')
f.write(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + "dos2unix over!\n")
f.close
return res
def build_clean():
f = open("output/time.txt",'a')
f.write(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + "build_clean start!\n")
f.close
work_path = config.RemotePath+"/build"
cmd = config.ssh + " -i "+ config.key_pri + " -l "+config.User + " "+config.Ip + " "
cmd = cmd + "cd "+work_path+";"
cmd = cmd + "cd build-ios-remote;"
cmd = cmd + "bash build_clean.sh "+config.RemoteWork
p = subprocess.Popen(cmd)
while p.poll() is None:
time.sleep(0.5)
res = p.returncode
if res != 0:
f = open("output/time.txt",'a')
f.write(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + "[Error]" + "build_clean fail!\n")
f.close
else:
f = open("output/time.txt",'a')
f.write(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + "build_clean over!\n")
f.close
return res
def build():
f = open("output/time.txt",'a')
f.write(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + "build start!\n")
f.close
work_path = config.RemotePath+"/build"
cmd_codesign = "security unlock-keychain -p "+config.Passwd+" /Users/"+config.User+"/Library/Keychains/login.keychain"
cmd_build = "python3 ./proc_build_ios_log.py "+config.UNITY_PATH+" "+config.PIPE_NAME+" "+config.PIPE_TYPE+" framw-unity "
cmd = config.ssh + " -i "+config.key_pri+" -l "+config.User+" "+config.Ip+ " "
cmd = cmd + "cd "+work_path+";"
cmd = cmd + cmd_codesign + ";"
cmd = cmd + "rm -f "+config.RemoteIPAPath+";"
cmd = cmd + cmd_build
p = subprocess.Popen(cmd)
while p.poll() is None:
time.sleep(0.5)
res = p.returncode
if res != 0:
f = open("output/time.txt",'a')
f.write(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + "[Error]" + "build fail!\n")
f.close
else:
f = open("output/time.txt",'a')
f.write(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + "buildn over!\n")
f.close
return res
def GetLog():
f = open("output/time.txt",'a')
f.write(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + "GetLog start!\n")
f.close
cmd = config.rsync + " -e '"+config.ssh+" -i "+config.key_pri+"' "+config.User+"@"+config.Ip+":"+config.RemoteLogPath+" "+config.LocalLogPath
p = subprocess.Popen(cmd)
while p.poll() is None:
time.sleep(0.5)
res = p.returncode
if res != 0:
f = open("output/time.txt",'a')
f.write(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + "[Error]" + "GetLog fail!\n")
f.close
else:
f = open("output/time.txt",'a')
f.write(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + "GetLog over!\n")
f.close
return res
def GetIpa():
f = open("output/time.txt",'a')
f.write(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + "GetIpa start!\n")
f.close
cmd = config.rsync + " -e '"+config.ssh+" -i "+config.key_pri+"' "+config.User+"@"+config.Ip+":"+config.RemoteIPAPath+" "+config.LocalIPAPath
p = subprocess.Popen(cmd)
while p.poll() is None:
time.sleep(0.5)
res = p.returncode
if res != 0:
f = open("output/time.txt",'a')
f.write(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + "[Error]" + "GetIpa fail!\n")
f.close
else:
f = open("output/time.txt",'a')
f.write(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + "GetIpa over!\n")
f.close
return res
if __name__ == '__main__':
res1 = MkWorkPath()
if res1 == 0:
print("MkWorkPath over!")
else:
print("MkWorkPath fail!")
sys.exit()
res2 = copy()
if res2 == 0 :
print("copy over!")
else:
print("copy fail!")
#sys.exit()
res4 = dos2unix()
if res4 == 0:
print("dos2unix over!")
else:
print("dos2unix fail!")
sys.exit()
res5 = build_clean()
if res5 == 0:
print("build_clean over!")
else:
print("build_clean fail")
res6 = build()
if res6 == 0:
print("build over!")
else:
print("build fail")
build_clean()
res7 = GetLog()
if res7 == 0:
print("GetLog over!")
else:
print("GetLog fail!")
sys.exit()
res8 = GetIpa()
if res8 == 0:
cmd = "explorer " + config.LocalOutPut
os.system(cmd)
f = open("output/time.txt",'a')
f.write(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + "------------------successful!-------------------\n\n\n\n")
f.close
print("GetIpa over!")
else:
f = open("output/time.txt",'a')
f.write(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + "------------------fail!-------------------------\n\n\n\n")
f.close
print("GetIpa fail!")
sys.exit()