提交 15853da0 创建 作者: 305350171@qq.com's avatar 305350171@qq.com

提交作业

上级 daa21943
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
"problemMatcher": "$msCompile" "problemMatcher": "$msCompile"
}, },
{ {
"label": "安装pip包(setup pip package)", "label": "安装python包",
"type": "shell", "type": "shell",
"windows": { "windows": {
"command": "pip install -i https://mirrors.aliyun.com/pypi/simple/ -r requirements.txt" "command": "pip install -i https://mirrors.aliyun.com/pypi/simple/ -r requirements.txt"
...@@ -82,10 +82,10 @@ ...@@ -82,10 +82,10 @@
"label": "提交作业(git push)", "label": "提交作业(git push)",
"type": "shell", "type": "shell",
"windows": { "windows": {
"command": "python customgitpush.py" "command": "python gitpush.py"
}, },
"linux": { "linux": {
"command": "python3 customgitpush.py" "command": "python3 gitpush.py"
}, },
"args": [], "args": [],
"group": "build", "group": "build",
......
...@@ -8,38 +8,43 @@ import filecmp ...@@ -8,38 +8,43 @@ import filecmp
import subprocess import subprocess
import platform import platform
print(
"************************************************************\n"
"如果下面报告类似 ImportError: No module named 'xxx' 的错误,\n"
"说明 python 运行环境中缺少必要的包。\n"
"此时可以启动\"安装python包\"任务来修复 python 运行环境(需要连接互联网)。\n"
"************************************************************\n"
)
from colorama import Fore, init, AnsiToWin32 from colorama import Fore, init, AnsiToWin32
init(wrap=False) init(wrap=False)
stream = AnsiToWin32(sys.stderr).stream stream = AnsiToWin32(sys.stderr).stream
if __name__ == "__main__": if __name__ == "__main__":
print(Fore.GREEN + "customgitpush.py version: 1.0", file = stream) print("gitpush.py version: 1.0")
print(Fore.WHITE, file = stream)
execResult = os.system("git add . && git commit -m \"提交作业\"") execResult = os.system("git add . && git commit -m \"提交作业\"")
if execResult == 256 or execResult == 1: if execResult == 256 or execResult == 1:
print("\n-------- 本次提交没有任何变更,即使推送成功,也不代表远程一定有提交记录 --------") print("\n-------- 本次提交没有任何变更,即使推送成功,也不代表远程一定有提交记录 --------")
print("-------- 请对项目中的文件进行修改后再进行提交-----------------------------------") print("-------- 请对项目中的文件进行修改后再进行提交-----------------------------------")
elif execResult == 128: elif execResult != 0:
print("\n-------- 推送到 Git 远程库失败 --------") print(Fore.RED + "\n-------- 提交作业失败! 错误码: {0}--------".format(execResult), file = stream)
print(Fore.WHITE, file = stream)
exit(0) exit(0)
print("\n-------------------------------------------------------------------------------") print("\n-------------------------------------------------------------------------------")
print("当弹出命令面板时请分别输入 Git 远程库的用户名和密码。通常为 CodeCode 密码。") print("请在 VSCode 顶部弹出的命令面板中输入 Git 远程库的用户名和密码。通常为 CodeCode 平台的用户名和密码。")
print("-------------------------------------------------------------------------------") print("-------------------------------------------------------------------------------")
print(Fore.GREEN + "正在提交作业...", file = stream)
print(Fore.WHITE, file = stream)
sys.stdout.flush()
execResult = os.system("git push") execResult = os.system("git push")
if execResult == 0: if execResult == 0:
print("\n-------- 推送到 Git 远程库成功 --------") print(Fore.GREEN + "\n-------- 提交作业成功! --------", file = stream)
print(Fore.WHITE, file = stream)
else: else:
print("\n--- 推送到 Git 远程库失败!想解决推送到 Git 远程库失败问题?使用浏览器访问下面链接即可。 ---") print(Fore.RED + "\n--- 提交作业失败! 想解决失败问题? 使用浏览器访问下面链接即可。 ---", file = stream)
print("https://www.codecode.net/engintime/codecode/publicmanual/blob/master/GitFAQ.md") print(Fore.RED + "https://www.codecode.net/engintime/codecode/publicmanual/blob/master/GitFAQ.md", file = stream)
print("复制方法:右键点击本窗口的标题栏,在菜单中选择“编辑”中的“标记”后,选中要复制的内容,按回车即可") print(Fore.WHITE, file = stream)
\ No newline at end of file
...@@ -10,7 +10,18 @@ import filecmp ...@@ -10,7 +10,18 @@ import filecmp
import subprocess import subprocess
import platform import platform
print("输出安装pip包的提示信息") bIncludeCi = False
if len(sys.argv) > 1 and sys.argv[1] == "ci":
bIncludeCi = True
if bIncludeCi == False:
print(
"************************************************************\n"
"如果下面报告类似 ImportError: No module named 'xxx' 的错误,\n"
"说明 python 运行环境中缺少必要的包。\n"
"此时可以启动\"安装python包\"任务来修复 python 运行环境(需要连接互联网)。\n"
"************************************************************\n"
)
from colorama import Fore, init, AnsiToWin32 from colorama import Fore, init, AnsiToWin32
init(wrap=False) init(wrap=False)
...@@ -151,25 +162,16 @@ def outputPromptInfo(bIncludeCi, promptInfo, color): ...@@ -151,25 +162,16 @@ def outputPromptInfo(bIncludeCi, promptInfo, color):
if __name__ == "__main__": if __name__ == "__main__":
bIncludeCi = False
if len(sys.argv) > 1 and sys.argv[1] == "ci":
bIncludeCi = True
if bIncludeCi == False: if bIncludeCi == False:
promptInfo = "提示:\n1.如果验证程序长时间未结束,说明应用程序中可能存在死循环。请停止验证程序,修改应用程序后再验证。\n2.如果提示‘python’不是内部或外部命令,也不是可运行的程序或批处理文件。需要设置 Python 的环境变量并重启开发环境来解决此问题。" print("开发环境中的 Python 解释器版本号:" + platform.python_version())
outputPromptInfo(bIncludeCi, promptInfo, 3)
print("开发环境中的 Python 解释器版本号:" + platform.python_version()) print()
print("环境变量中的 Python 解释器版本号:", end=' ')
sys.stdout.flush() compResultFile = "result_comparation.html"
execResult = os.system("python --version") if os.path.isfile(compResultFile):
if execResult != 0: os.remove(compResultFile)
errorInfo = "应用程序异常,返回值:{0}。".format(execResult)
outputPromptInfo(bIncludeCi, errorInfo, 2)
exit(1)
print()
promptInfo = "正在使用make生成项目" promptInfo = "正在使用make生成项目"
outputPromptInfo(bIncludeCi, promptInfo, 1) outputPromptInfo(bIncludeCi, promptInfo, 1)
...@@ -227,6 +229,10 @@ if __name__ == "__main__": ...@@ -227,6 +229,10 @@ if __name__ == "__main__":
promptInfo = "执行的命令是: {0}".format(runCommand) promptInfo = "执行的命令是: {0}".format(runCommand)
outputPromptInfo(bIncludeCi, promptInfo, 0) outputPromptInfo(bIncludeCi, promptInfo, 0)
if bIncludeCi == False:
promptInfo = "提示:如果验证程序长时间未结束,说明应用程序中可能存在死循环。请停止验证程序(Ctrl+c),修改应用程序后再验证。"
outputPromptInfo(bIncludeCi, promptInfo, 3)
execResult = os.system(runCommand) execResult = os.system(runCommand)
if execResult != 0: if execResult != 0:
errorInfo = "应用程序执行异常,返回值:{0}。".format(execResult) errorInfo = "应用程序执行异常,返回值:{0}。".format(execResult)
...@@ -243,7 +249,7 @@ if __name__ == "__main__": ...@@ -243,7 +249,7 @@ if __name__ == "__main__":
# errorInfo = "输出结果比较异常,返回值:{0}。".format(execResult) # errorInfo = "输出结果比较异常,返回值:{0}。".format(execResult)
# outputPromptInfo(bIncludeCi, errorInfo, 2) # outputPromptInfo(bIncludeCi, errorInfo, 2)
else: else:
promptInfo = "提示:\n请使用以下方式打开文件的比较结果:\n选择View菜单中的Explorer菜单项,在打开的文件列表中,右击result_comparation.html文件,\n在弹出的菜单中选择“Open Preview”菜单项,可以打开比较结果输出文件,可帮助用户查找验证失败的原因。" promptInfo = "查看文件比较结果可帮助你查找验证失败的原因。方法是:\n选择 View 菜单中的 Explorer 打开文件列表,右键点击 result_comparation.html 文件,在弹出的菜单中选择 Open Preview"
outputPromptInfo(bIncludeCi, promptInfo, 2) outputPromptInfo(bIncludeCi, promptInfo, 2)
exit(1) exit(1)
seqNum = seqNum + 1 seqNum = seqNum + 1
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论