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

提交作业

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

    代码质量分析发现了 3 个问题。

    • 0 blocker
    • 🚫 0 critical
    • 0 major
    • 🔽 1 minor
    • 2 info

    注意: 存在下列问题的代码行在本次提交中没有发生变更,无法使用代码行评论的方式进行报告。所以将下列问题汇总显示在这里(点击问题链接可以转到对应的源代码行):

    1. 🔽 Cppcheck cannot find all the include files. Cppcheck can check the code without the include files found. But the results will probably be more accurate if all the include files are found. Please check your project's include directories and add all of them as include directories for Cppcheck. To see what files Cppcheck cannot find use --check-config. (ProjectKey-169403) 📘
    2. keyword 'if' not followed by a single space 📘
    3. keyword 'if' not followed by a single space 📘
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论