Merge branch 'backend_dev' of gitlab2.kylin.com:kylin-desktop/update-manager-group/kylin-system-updater into backend_dev

This commit is contained in:
luoxueyi 2021-11-30 19:39:28 +08:00
commit aefc6436d8
1 changed files with 27 additions and 10 deletions

View File

@ -34,19 +34,31 @@ class InstallBackendAptdaemon(InstallBackend):
self.client = client.AptClient()
self.trans_failed_msg = None
#模拟发送使用的进度
self.simulation_progress = 0
#aptdeamon的实时进度
self.trans_progress = 0
self.static_progress = 0
# 活跃性检查 才使用的进度
self.check_progress = 0
self.trans_status = ''
self.details = ''
self.on_install_stage = False
self.trans_cancelable = False
self.last_action_timestamp = time.time()
if self.action == self.ACTION_INSTALL:
#定时模拟发送进度 为了让进度更加线性
if self.action == self.ACTION_UPDATE:
#超时检查轮询
logging.info("timeout_add_seconds init...")
GLib.timeout_add_seconds(UPDATER_IDLE_CHECK_INTERVAL,
self._check_for_inactivity)
GLib.timeout_add_seconds(1,self._check_simulation_progress)
def _check_simulation_progress(self):
self.simulation_progress += 20
if self.trans_progress >= 90 or self.simulation_progress > 80:
return False
else:
self._dist_status_changed(self.action,[],self.simulation_progress,self.trans_status,self.details)
return True
def _check_for_inactivity(self):
"""Shutdown the daemon if it has been inactive for time specified
@ -58,14 +70,14 @@ class InstallBackendAptdaemon(InstallBackend):
logging.info("Installing to exit and timeout check quit...")
return False
#进度不同时 更新时间戳
if self.trans_progress != self.static_progress:
self.static_progress = self.trans_progress
if self.trans_progress != self.check_progress:
self.check_progress = self.trans_progress
self.last_action_timestamp = time.time()
#只有安装的时候启用 下载时候不使用
timestamp = self.last_action_timestamp
if (time.time() - timestamp > UPDATER_IDLE_TIMEOUT
and self.static_progress > 50):
and self.check_progress > 50):
logging.error("Quitting due to inactivity(%s)",self.details)
self._action_done(self.ACTION_INSTALL,
is_cancelled=False, success=False,
@ -240,8 +252,10 @@ class InstallBackendAptdaemon(InstallBackend):
#进度回调
def _on_progress_changed(self, trans,progress,action):
#不要101这种未知状态
if progress == 101:
return
self.trans_progress = progress
self._dist_status_changed(action,self.now_upgrade.upgrade_groups+self.now_upgrade.single_pkgs,\
self.trans_progress,self.trans_status,self.details)
@ -257,7 +271,10 @@ class InstallBackendAptdaemon(InstallBackend):
#分发进度状态和细节信息
def _dist_status_changed(self,action,upgrade_content = [],progress = 0,status = '',details = ''):
if action == self.ACTION_UPDATE: # 更新进度100后推迟发出100%的信号 -- 等待源过滤完成
if self.trans_progress != 100:
if progress == 11:
progress = 15
if progress != 100:
self.window_main.dbusController.UpdateDetectStatusChanged(progress,status)
elif action == self.ACTION_INSTALL:
#50%时候 属于下载状态切换到安装状态的过程