增加取消信号在下载阶段的频发

This commit is contained in:
wangsong 2021-11-25 10:21:24 +08:00
parent 00d45c13a2
commit b9bc2feadd
2 changed files with 14 additions and 9 deletions

View File

@ -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')

View File

@ -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)