Browse Source

重点修改:执行编译脚本时,不能重定向,否则无法生成日志文件。

Jeff 3 years ago
parent
commit
83384a9a51

+ 3 - 1
自动编译系统脚本标准化/51M-CompileScript.sh

@@ -171,7 +171,9 @@ initArgument()
     # Clean编译:用户手动选择,则true,否则不选或n都为关闭;
     if [ x$Arg_CleanBuild = "xy" ]; then
         Arg_CleanBuild=true
-    else
+    elif [ x$Arg_CleanBuild = "x" ];then
+        Arg_CleanBuild=false
+    elif [ x$Arg_CleanBuild = "xn" ];then
         Arg_CleanBuild=false
     fi
     

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

@@ -15,6 +15,8 @@ if len(sys.argv) == 2:
     JSONFILE = sys.argv[1]  # 表示Json参数文件路径;
 if len(sys.argv) == 3:
     SHELLFILE = sys.argv[2]  # 表示Shell脚本文件路径;
+# 输入开始时间;  
+print("Start",time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
 
 # 源码路径
 CODE_DIR = None
@@ -71,16 +73,16 @@ def loadJson():
 
 
 # 不使用重定向;
-def cmdExecute2(cmd,dir=os.getcwd()):
-    # 定义文件名称;
-    file_name = str(time.time())
+def cmdExecute2(cmd, dir=None):
+    print(str.format("cmd start:%s, %s") % (cmd, time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())))
     proc = subprocess.Popen(cmd, shell=True, cwd=dir)
     # 等待完成;
     proc.wait()
+    print(str.format("cmd end:%s, %s") % (cmd, time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())))
 
 
 def cmdExecute(cmd, dir=None):
-    print(cmd)
+    print(str.format("cmd start:%s, %s") % (cmd, time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())))
     proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, cwd=dir)
     # 等待完成;
     stdout,stderr = proc.communicate()
@@ -88,12 +90,14 @@ def cmdExecute(cmd, dir=None):
         print(u'cmd finished')
     # 返回执行结果;
     print(stdout)
+    print(str.format("cmd end:%s, %s") % (cmd, time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())))
     return stdout
 
 
 def prev_compile():
     global PREV_ARG
     global CODE_DIR
+    print("prev_compile", time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
     if PREV_ARG is None or PREV_ARG.__len__() == 0:
         print("prev args is empty")
         return False
@@ -110,13 +114,15 @@ def prev_compile():
 
     # 更新代码;
     commands=None
-    if PREV_ARG['sync']:
+    if 'sync' in PREV_ARG and PREV_ARG['sync']:
+        print("start sync")
         commands = str.format("cd %s;repo sync") % CODE_DIR
         cmdExecute(commands, CODE_DIR)
     
     # 重新下载;
     commands=[]
     if PREV_ARG['redownload']:
+        print("start redownload")
         commands.append(str.format("cd %s") % CODE_DIR)
         commands.append(str.format("rm -rf !(%s|%s|%s|%s)") % ("builder.py", "arg.json", "51M-CompileScript.sh", "ftp.py"))
         # 已在编译路径中,无须处理;
@@ -131,6 +137,7 @@ def prev_compile():
 
 def call_script():
     global SCRIPT_ARG
+    print("call_script", time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
     if SCRIPT_ARG is None or SCRIPT_ARG.__len__() == 0:
         print("script args is empty")
         return False
@@ -148,13 +155,15 @@ def call_script():
         return False
 
     print("start to compile")
-    cmdExecute(str.format("cd %s;chmod 777 %s;./%s %s")%(CODE_DIR,SCRIPT_NAME,SCRIPT_NAME,commandline), CODE_DIR)
+    # 调用编译脚本时,不需要重定向,否则无法生成日志;
+    cmdExecute2(str.format("cd %s;chmod 777 %s;./%s %s")%(CODE_DIR,SCRIPT_NAME,SCRIPT_NAME,commandline), CODE_DIR)
 
     return True
 
 
 def after_compile():
     global AFTER_ARG
+    print("after_compile", time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
     if AFTER_ARG is None or AFTER_ARG.__len__() == 0:
         print("after args is empty")
         return False