From a474253912b2f4e525462f58444ce34d1e72fc89 Mon Sep 17 00:00:00 2001 From: HeXiangLong <3234374354@qq.com> Date: Tue, 8 Apr 2025 22:34:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8=20main.py=20=E4=B8=AD=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=AF=B9=20'update'=20=E5=91=BD=E4=BB=A4=E7=9A=84?= =?UTF-8?q?=E6=94=AF=E6=8C=81=EF=BC=8C=E5=AE=9E=E7=8E=B0=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=B9=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96=20'ls'=20=E5=91=BD=E4=BB=A4=E7=9A=84=E5=A4=84?= =?UTF-8?q?=E7=90=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/main.py b/main.py index e2023a1..0aa0fc1 100644 --- a/main.py +++ b/main.py @@ -73,17 +73,24 @@ def pseudo_zsh(): except FileNotFoundError: print(f"cd: no such file or directory: {args[1]}") # 目录不存在 continue - if args[0] == 'ls': - if len(args) == 1: - args.append('-l') # 默认参数 - subprocess.run(['ls'] + args[1:]) # 执行 ls 命令 + if args[0] == 'l': - if len(args) == 1: - args.append('-l') - subprocess.run(['ls'] + args[1:]) + subprocess.run(['ls','-l']) # 执行 ls 命令 + if args[0] == 'ssh1': subprocess.run(['ssh','root@10.147.17.161']) - if args[0] == 'sudo': + + if args[0] == 'update': + try: + subprocess.run(['git', 'pull']) + subprocess.run(['git', 'push']) + print("Code synchronized successfully.") + print("Restarting the program...") + os.execv(sys.executable, ['python3'] + sys.argv) # 重新运行程序 + except Exception as e: + print(f"Error during update: {e}") + + if args[0] == 'sudo': flight1 = True a = 0 for attempt in range(3): # 循环 3 次