From b9bc2feaddd8bbfec5633ec43807b52d3c95ca42 Mon Sep 17 00:00:00 2001 From: wangsong Date: Thu, 25 Nov 2021 10:21:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8F=96=E6=B6=88=E4=BF=A1?= =?UTF-8?q?=E5=8F=B7=E5=9C=A8=E4=B8=8B=E8=BD=BD=E9=98=B6=E6=AE=B5=E7=9A=84?= =?UTF-8?q?=E9=A2=91=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/SystemUpdater/UpdateManagerDbus.py | 4 ++-- .../backend/InstallBackendAptdaemon.py | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/backend/SystemUpdater/UpdateManagerDbus.py b/backend/SystemUpdater/UpdateManagerDbus.py index 6eaa99e..3356659 100755 --- a/backend/SystemUpdater/UpdateManagerDbus.py +++ b/backend/SystemUpdater/UpdateManagerDbus.py @@ -443,8 +443,8 @@ class UpdateManagerDbusController(dbus.service.Object): # 信号是否可取消 @dbus.service.signal(UPDATER_DBUS_INTERFACE, signature='b') def Cancelable(self, Cancelable): - logging.info(COLORLOG_PREFIX + "emit" + COLORLOG_SUFFIX +" Cancelable: %r",\ - Cancelable) + pass + # logging.info(COLORLOG_PREFIX + "emit" + COLORLOG_SUFFIX +" Cancelable: %r",Cancelable) # 插入数据库完成后发送 @dbus.service.signal(UPDATER_DBUS_INTERFACE, signature='ss') diff --git a/backend/SystemUpdater/backend/InstallBackendAptdaemon.py b/backend/SystemUpdater/backend/InstallBackendAptdaemon.py index fcd6424..61dd026 100644 --- a/backend/SystemUpdater/backend/InstallBackendAptdaemon.py +++ b/backend/SystemUpdater/backend/InstallBackendAptdaemon.py @@ -37,8 +37,8 @@ class InstallBackendAptdaemon(InstallBackend): self.static_progress = 0 self.trans_status = '' self.details = '' - self.is_enter_install = False - + self.on_install_stage = False + self.trans_cancelable = False self.last_action_timestamp = time.time() if self.action == self.ACTION_INSTALL: @@ -259,13 +259,15 @@ class InstallBackendAptdaemon(InstallBackend): if self.trans_progress != 100: self.window_main.dbusController.UpdateDetectStatusChanged(progress,status) elif action == self.ACTION_INSTALL: - if progress >= 50 and self.is_enter_install == False: - self.is_enter_install = True + #50%时候 属于下载状态切换到安装状态的过程 + if progress >= 51 and self.on_install_stage == False: + self.on_install_stage = True #进度安装阶段标志位,使用鉴别是否出现安装过程中强制关闭 之后进行修复使用得 self.window_main.configs.setValue("SystemStatus","isabnormalreboot",str(True),True) pass #LockedPreventShutdown() - - #此处发不发信号一样 频率很低 + #在下载阶段发送取消信号 + if self.on_install_stage == False: + self.window_main.dbusController.Cancelable(self.trans_cancelable) self.window_main.dbusController.UpdateDloadAndInstStaChanged(upgrade_content,progress,status,details) # elif action == self.ACTION_FIX_BROKEN: # self.window_main.dbusController.FixBrokenStatusChanged(progress,status) @@ -294,7 +296,10 @@ class InstallBackendAptdaemon(InstallBackend): humanize_size(current_cps)) def _on_cancellable_changed(self, trans, Cancelable): + logging.info("\033[43;1m" + "emit" + "\033[0m" +" Cancelable: %r",Cancelable) self.window_main.dbusController.Cancelable(Cancelable) + #增加取消信号的频发机制 + self.trans_cancelable = Cancelable #增加记录当产生错误的时候 详细信息 def _on_error_changed(self, trans,error_code, error_details): @@ -322,7 +327,7 @@ class InstallBackendAptdaemon(InstallBackend): error_desc = '' #退出 - self.is_enter_install = False + self.on_install_stage = False if status == EXIT_FAILED: error_string = get_error_string_from_enum(trans.error.code) error_desc = get_error_description_from_enum(trans.error.code)