From fed594d37895d0791348102dd08c2d1d4b787381 Mon Sep 17 00:00:00 2001 From: wangsong Date: Wed, 19 Jan 2022 09:37:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=A4=E6=96=AD=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E9=9C=80=E8=A6=81=E6=B3=A8=E9=94=80=E4=BB=A5=E5=8F=8A?= =?UTF-8?q?=E9=87=8D=E5=90=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/SystemUpdater/UpdateManager.py | 12 ------------ backend/SystemUpdater/UpdateManagerDbus.py | 5 +++++ backend/SystemUpdater/backend/__init__.py | 18 ++++++++++++++++++ backend/interface.md | 21 +++++++++++++++++++-- 4 files changed, 42 insertions(+), 14 deletions(-) diff --git a/backend/SystemUpdater/UpdateManager.py b/backend/SystemUpdater/UpdateManager.py index ad55e0e..b3457a6 100644 --- a/backend/SystemUpdater/UpdateManager.py +++ b/backend/SystemUpdater/UpdateManager.py @@ -275,8 +275,6 @@ class UpdateManager(): upgrade_list = self.update_list.local_upgrade_data.upgrade_groups + self.update_list.local_upgrade_data.single_pkgs #发送更新升级列表完成的标志 self.dbusController.DistUpdateDetectFinished(_success,upgrade_list,header,desc) - #检查安装完成之后需要重启吗 - self.is_reboot_required() #清空cache if self.cache != None and self.cache.get_changes(): self.cache.clear() @@ -435,16 +433,6 @@ class UpdateManager(): return _success,header,desc - def is_reboot_required(self): - """If a reboot is required to get all changes into effect.""" - return os.path.exists(os.path.join(apt_pkg.config.find_dir("Dir"), - "var/run/reboot-required")) - - def is_logout_required(self): - """If a reboot is required to get all changes into effect.""" - return os.path.exists(os.path.join(apt_pkg.config.find_dir("Dir"), - "var/run/logout-required")) - def _check_cache_broken(self,cache): with cache.actiongroup(): if cache.get_changes(): diff --git a/backend/SystemUpdater/UpdateManagerDbus.py b/backend/SystemUpdater/UpdateManagerDbus.py index 6be8224..125240c 100755 --- a/backend/SystemUpdater/UpdateManagerDbus.py +++ b/backend/SystemUpdater/UpdateManagerDbus.py @@ -558,3 +558,8 @@ class UpdateManagerDbusController(dbus.service.Object): @dbus.service.signal(UPDATER_DBUS_INTERFACE, signature='sa{sv}') def KumSnapSignal(self, type_msg, msg): logging.info(COLORLOG_PREFIX + "Emitting" + COLORLOG_SUFFIX +" KumSnapSignal type_msg = %s,msg = %s",type_msg,str(msg)) + + #重启和注销请求信号 + @dbus.service.signal(UPDATER_DBUS_INTERFACE,signature='s') + def RebootLogoutRequired(self,required_status=''): + logging.info(COLORLOG_PREFIX + "Emitting"+ COLORLOG_SUFFIX + " RebootLogoutRequired required_status = %s",required_status) \ No newline at end of file diff --git a/backend/SystemUpdater/backend/__init__.py b/backend/SystemUpdater/backend/__init__.py index e9b07b0..3649be6 100644 --- a/backend/SystemUpdater/backend/__init__.py +++ b/backend/SystemUpdater/backend/__init__.py @@ -8,6 +8,7 @@ import os from gettext import gettext as _ import apt +import apt_pkg from SystemUpdater.Core.utils import ( unLockedEnableShutdown, check_free_space, @@ -437,6 +438,12 @@ class InstallBackend(): self.cache.clear() self.window_main.dbusController.UpdateInstallFinished(success,upgrade_content,error_string,error_desc) + + #更新完成之后检查是否需要重启 + if self.is_reboot_required() == True: + self.window_main.dbusController.RebootLogoutRequired("reboot") + elif self.is_logout_required() == True: + self.window_main.dbusController.RebootLogoutRequired("logout") elif action == self.ACTION_UPDATE: if success == False and 'The following signatures' in self.trans_error_details: @@ -541,6 +548,17 @@ class InstallBackend(): except Exception as e: logging.error(str(e)) + + def is_reboot_required(self): + """If a reboot is required to get all changes into effect.""" + return os.path.exists(os.path.join(apt_pkg.config.find_dir("Dir"), + "var/run/reboot-required")) + + def is_logout_required(self): + """If a logout is required to get all changes into effect.""" + return os.path.exists(os.path.join(apt_pkg.config.find_dir("Dir"), + "var/run/logout-required")) + # try aptdaemon if os.path.exists("/usr/sbin/aptd") \ and "UPDATE_MANAGER_FORCE_BACKEND_SYNAPTIC" not in os.environ: diff --git a/backend/interface.md b/backend/interface.md index eb9de98..1c0b3a4 100755 --- a/backend/interface.md +++ b/backend/interface.md @@ -200,7 +200,7 @@ | FixBrokenStatusChanged | iiisss | 修复依赖的状态信号 | | PurgePackagesFinished | iss | 卸载完成信号 | | PurgePkgStatusChanged | bss | 卸载进度信息以及状态信息 | -| | | | +| RebootLogoutRequired | s | 请求重启或者注销的信号 | | | | | @@ -373,7 +373,24 @@ InstalldebFinished success = False , error_string = 下载软件包文件失败 , error_desc = 检查您的网络连接。 ``` - + + + +#### RebootLogoutRequired + +- `介绍:`请求重启和注销的信号 + +- `出参`: `s:` "reboot" 表示重启 "logout"表示注销 + +- `示例:` + + ```sh + Emitting RebootLogoutRequired required_status = reboot + ``` + + + +