Browse Source

编译完成后,scp目标文件到指定服务器。

JeffWang 2 years ago
parent
commit
a42c696ac3
1 changed files with 25 additions and 2 deletions
  1. 25 2
      自动编译系统脚本标准化/builder.py

+ 25 - 2
自动编译系统脚本标准化/builder.py

@@ -127,7 +127,7 @@ def prev_compile():
     #commands.append("export PATH=$(echo $PATH)") 
     if 'clean' in PREV_ARG and PREV_ARG['clean']:
         print("enable clean")
-        commands.append("repo forall -c \"pwd &&git clean -xfd && git checkout --\"")
+        commands.append("repo forall -c \"pwd &&git clean -xfd && git checkout .\"")
 
     # 更新代码;
     if 'sync' in PREV_ARG and PREV_ARG['sync']:
@@ -137,7 +137,7 @@ def prev_compile():
     # 重新下载;
     if 'redownload' in PREV_ARG and PREV_ARG['redownload']:
         print("enable redownload")
-        commands.append(str.format("rm -rf !(%s|%s|%s|%s)") % ("builder.py", "arg.json", "51M-CompileScript.sh", "ftp.py"))
+        commands.append(str.format("rm -rf !(%s|%s|%s|%s)") % ("builder.py", "arg.json", SCRIPT_NAME, "ftp.py"))
         commands.append(str.format("repo init -u %s") % (PREV_ARG['branch-addr']))
         commands.append("repo sync")   
     
@@ -179,6 +179,29 @@ def after_compile():
         print("after args is empty")
         return False
 
+    if 'Scp2OtherServer' in AFTER_ARG:
+        if type(AFTER_ARG['Scp2OtherServer']) == type(u'str'):
+            AFTER_ARG['Scp2OtherServer'] = True if AFTER_ARG['Scp2OtherServer'].lower() == u'true' else False
+        print(type(AFTER_ARG['Scp2OtherServer']), AFTER_ARG['Scp2OtherServer'])
+    
+    # 上传到其他服务器;
+    if 'Scp2OtherServer' in AFTER_ARG and AFTER_ARG['Scp2OtherServer']:
+        commands=[]
+        commands.append(str.format("cd %s/Target/") % CODE_DIR)
+        commands.append("cd $(ls|grep V8)")
+        commands.append("pwd")
+        commands.append("ls")
+        # 创建目录;
+        ScpDir=AFTER_ARG['ScpServerPath']+time.strftime("%Y%m%d%H%M%S")
+        commands.append(str.format('ssh %s@%s "[ -d %s ] && echo ok || mkdir -p %s"') % (AFTER_ARG['ScpUserName'], AFTER_ARG['ScpServerName'], ScpDir, ScpDir))
+        commands.append(str.format("scp -r OTA %s@%s:%s") % (AFTER_ARG['ScpUserName'], AFTER_ARG['ScpServerName'], ScpDir))
+        commands.append(str.format("scp -r Reports/* %s@%s:%s") % (AFTER_ARG['ScpUserName'], AFTER_ARG['ScpServerName'], ScpDir))
+        commands.append(str.format("scp -r USB/* %s@%s:%s") % (AFTER_ARG['ScpUserName'], AFTER_ARG['ScpServerName'], ScpDir))
+
+        # 执行所有命令;
+        commandline=';'.join(commands)    
+        cmdExecute_Ridrect(commandline)
+
 
 if __name__ == "__main__":
     # os.system('cd ~/2851M; ls -al; repo sync') # 可用命令格式;