更新时候的模拟进度修改
This commit is contained in:
parent
03311b14ae
commit
2b5c667cf9
|
@ -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,
|
||||
|
@ -242,6 +254,10 @@ class InstallBackendAptdaemon(InstallBackend):
|
|||
def _on_progress_changed(self, trans,progress,action):
|
||||
if progress == 101:
|
||||
return
|
||||
|
||||
if progress == 11:
|
||||
progress = 10
|
||||
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue