|
21 | 21 | if str(PATH_ROOT) not in sys.path: |
22 | 22 | sys.path.insert(0, str(PATH_ROOT)) |
23 | 23 |
|
24 | | -from git_update_helpers import ( |
| 24 | +from desktop_qt_ui.core.git_update_helpers import ( |
25 | 25 | GIT_MIRRORS as SHARED_GIT_MIRRORS, |
26 | 26 | ) |
27 | | -from git_update_helpers import ( |
| 27 | +from desktop_qt_ui.core.git_update_helpers import ( |
28 | 28 | SUPPORTED_BRANCHES as SHARED_SUPPORTED_BRANCHES, |
29 | 29 | ) |
30 | | -from git_update_helpers import ( |
| 30 | +from desktop_qt_ui.core.git_update_helpers import ( |
31 | 31 | current_branch as shared_current_branch, |
32 | 32 | ) |
33 | | -from git_update_helpers import ( |
| 33 | +from desktop_qt_ui.core.git_update_helpers import ( |
34 | 34 | fetch_origin, |
35 | 35 | git_output, |
36 | 36 | set_origin_url, |
37 | 37 | ) |
38 | | -from git_update_helpers import ( |
| 38 | +from desktop_qt_ui.core.git_update_helpers import ( |
39 | 39 | update_branch as shared_update_branch, |
40 | 40 | ) |
41 | 41 |
|
@@ -693,33 +693,20 @@ def restart_maintenance(action): |
693 | 693 | raise SystemExit(1) from e |
694 | 694 |
|
695 | 695 | def restart_desktop_ui(): |
696 | | - """Start a fresh desktop UI process after automatic maintenance finishes.""" |
697 | | - try: |
698 | | - if sys.platform == "win32": |
699 | | - start_script = PATH_ROOT / "Win-Start.bat" |
700 | | - if start_script.exists(): |
701 | | - subprocess.Popen( |
702 | | - ["cmd.exe", "/d", "/c", str(start_script)], |
703 | | - cwd=PATH_ROOT, |
704 | | - creationflags=( |
705 | | - subprocess.CREATE_NEW_PROCESS_GROUP |
706 | | - | subprocess.DETACHED_PROCESS |
707 | | - ), |
708 | | - ) |
709 | | - return True |
710 | | - unix_start = PATH_ROOT / "Unix-Start.sh" |
711 | | - if unix_start.exists(): |
712 | | - subprocess.Popen( |
713 | | - [str(unix_start)], |
714 | | - cwd=PATH_ROOT, |
715 | | - start_new_session=True, |
716 | | - ) |
717 | | - return True |
718 | | - subprocess.Popen( |
719 | | - [sys.executable, str(PATH_ROOT / "desktop_qt_ui" / "main.py")], |
720 | | - cwd=PATH_ROOT, |
721 | | - start_new_session=True, |
| 696 | + """Restart the desktop UI with the interpreter that completed maintenance.""" |
| 697 | + command = [sys.executable, str(PATH_ROOT / "desktop_qt_ui" / "main.py")] |
| 698 | + kwargs = {"cwd": PATH_ROOT} |
| 699 | + if sys.platform == "win32": |
| 700 | + kwargs["creationflags"] = ( |
| 701 | + subprocess.CREATE_NEW_PROCESS_GROUP | subprocess.DETACHED_PROCESS |
722 | 702 | ) |
| 703 | + else: |
| 704 | + kwargs["start_new_session"] = True |
| 705 | + |
| 706 | + print(L("正在重新启动桌面端...", "Restarting the desktop UI...")) |
| 707 | + sys.stdout.flush() |
| 708 | + try: |
| 709 | + subprocess.Popen(command, **kwargs) |
723 | 710 | return True |
724 | 711 | except OSError as exc: |
725 | 712 | print( |
@@ -2941,13 +2928,16 @@ def __init__(self): |
2941 | 2928 | if not resume_updated_code(args, resume_action): |
2942 | 2929 | raise SystemExit(1) |
2943 | 2930 | if automatic: |
2944 | | - restart_desktop_ui() |
| 2931 | + if not restart_desktop_ui(): |
| 2932 | + raise SystemExit(1) |
2945 | 2933 | return |
2946 | 2934 | input(L("\n按回车键继续...", "\nPress Enter to continue...")) |
2947 | 2935 |
|
2948 | 2936 | if automatic: |
2949 | | - run_full_update(args, automatic=True) |
2950 | | - restart_desktop_ui() |
| 2937 | + if not run_full_update(args, automatic=True): |
| 2938 | + raise SystemExit(1) |
| 2939 | + if not restart_desktop_ui(): |
| 2940 | + raise SystemExit(1) |
2951 | 2941 | return |
2952 | 2942 |
|
2953 | 2943 | # 首次显示版本信息 |
|
0 commit comments