增加安装的进度信号
This commit is contained in:
parent
623f01e340
commit
25b4d1d7a6
|
@ -116,17 +116,23 @@ class UpdateManagerDbusController(dbus.service.Object):
|
|||
self.transaction.cancel()
|
||||
return True
|
||||
|
||||
#更新和升级的进度信息 0~100 进度信息 101为非预期的信号
|
||||
#更新进度信息 0~100 进度信息 101为非预期的信号
|
||||
@dbus.service.signal(INTERFACE,signature='is')
|
||||
def update_progress_signal(self,progress,status):
|
||||
logging.info("emit progress = %d , status = %s",progress,status)
|
||||
|
||||
#更新完成的信号
|
||||
@dbus.service.signal(INTERFACE,signature='basss')
|
||||
def update_finished_signal(self, success, upgrade_group,error_string='',error_desc='',):
|
||||
logging.info("emit success = %r , upgrade_group = %a, error_string = %s , error_desc = %s ",\
|
||||
success,upgrade_group, error_string,error_desc)
|
||||
pass
|
||||
|
||||
#升级的进度信息 0~100 进度信息 101为非预期的信号
|
||||
@dbus.service.signal(INTERFACE,signature='asis')
|
||||
def upgrade_progress_signal(self,groups_list,progress,status):
|
||||
logging.info("emit groups_list = %s progress = %d , status = %s",groups_list,progress,status)
|
||||
|
||||
#发送下载包信息
|
||||
@dbus.service.signal(INTERFACE, signature='iiiiii')
|
||||
def on_download_changed_signal(self, current_items, total_items, currenty_bytes, total_bytes, current_cps, eta):
|
||||
|
|
|
@ -15,10 +15,8 @@ from aptdaemon.enums import (EXIT_SUCCESS,
|
|||
from UpdateManager.backend import InstallBackend
|
||||
import logging
|
||||
from gettext import gettext as _
|
||||
|
||||
import dbus
|
||||
|
||||
|
||||
class InstallBackendAptdaemon(InstallBackend):
|
||||
"""Makes use of aptdaemon to refresh the cache and to install updates."""
|
||||
|
||||
|
@ -82,14 +80,23 @@ class InstallBackendAptdaemon(InstallBackend):
|
|||
authorized=True, success=False,
|
||||
error_string=None, error_desc=None)
|
||||
raise
|
||||
|
||||
def _on_progress_changed(self, trans, progress):
|
||||
|
||||
#进度回调
|
||||
def _on_progress_changed(self, trans,progress,action):
|
||||
self.trans_progress = progress
|
||||
self.window_main.dbusController.update_progress_signal(self.trans_progress,self.trans_status)
|
||||
if action == self.ACTION_UPDATE:
|
||||
self.window_main.dbusController.update_progress_signal(self.trans_progress,self.trans_status)
|
||||
else:
|
||||
self.window_main.dbusController.upgrade_progress_signal(self.upgrade_groups_list,self.trans_progress,self.trans_status)
|
||||
|
||||
def _on_status_changed(self, trans, status):
|
||||
#同步状态回调
|
||||
def _on_status_changed(self, trans, status,action):
|
||||
self.trans_status = status
|
||||
self.window_main.dbusController.update_progress_signal(self.trans_progress,self.trans_status)
|
||||
if action == self.ACTION_UPDATE:
|
||||
self.window_main.dbusController.update_progress_signal(self.trans_progress,self.trans_status)
|
||||
else:
|
||||
#升级的时候发送状态信号时需要上传更新组信息self.upgrade_groups_list
|
||||
self.window_main.dbusController.upgrade_progress_signal(self.upgrade_groups_list,self.trans_progress,self.trans_status)
|
||||
|
||||
def _on_details_changed(self, trans, details):
|
||||
logging.info(details)
|
||||
|
@ -98,10 +105,6 @@ class InstallBackendAptdaemon(InstallBackend):
|
|||
logging.info(details)
|
||||
|
||||
def _on_progress_download_changed(self,trans,current_items, total_items, currenty_bytes, total_bytes, current_cps, eta):
|
||||
# logging.info("current_items = %d, total_items = %d, currenty_bytes = %d, total_bytes = %d, current_cps = %d, eta = %d .",\
|
||||
# current_items, total_items, \
|
||||
# currenty_bytes, total_bytes, \
|
||||
# current_cps, eta)
|
||||
if self.action == self.ACTION_INSTALL:
|
||||
self.window_main.dbusController.on_download_changed_signal(\
|
||||
current_items, total_items, \
|
||||
|
@ -113,29 +116,28 @@ class InstallBackendAptdaemon(InstallBackend):
|
|||
|
||||
@inline_callbacks
|
||||
def _show_transaction(self, trans, action, header, show_details):
|
||||
|
||||
# progressbar = AptProgressBar(trans)
|
||||
# trans.connect("status-details-changed", self._on_details_changed)
|
||||
#状态改变的时候的回调函数
|
||||
|
||||
#update 更新完成的时候的回调
|
||||
trans.connect("finished", self._on_finished, action)
|
||||
# trans.connect("medium-required", self._on_medium_required)
|
||||
|
||||
trans.connect("status-changed", self._on_status_changed)
|
||||
|
||||
trans.connect("progress-changed", self._on_progress_changed)
|
||||
|
||||
# trans.connect("progress-details-changed", self._on_progress_download_changed)
|
||||
#升级和更新的状态信息
|
||||
trans.connect("status-changed", self._on_status_changed,action)
|
||||
trans.connect("progress-changed", self._on_progress_changed,action)
|
||||
|
||||
#取消标志位
|
||||
trans.connect("cancellable-changed", self._on_cancellable_changed)
|
||||
|
||||
#下载的进度信息
|
||||
trans.connect("progress-details-changed", self._on_progress_download_changed)
|
||||
|
||||
# trans.connect("medium-required", self._on_medium_required)
|
||||
|
||||
# trans.connect("status-details-changed", self._on_details_changed)
|
||||
#状态改变的时候的回调函数
|
||||
# trans.connect("download-changed", self._on_download_changed)
|
||||
|
||||
# trans.connect("config-file-conflict", self._on_config_file_conflict)
|
||||
|
||||
# yield trans.set_debconf_frontend("ukui")
|
||||
trans.set_locale('en@UTF-8')
|
||||
yield trans.run()
|
||||
|
||||
def _on_finished(self, trans, status, action):
|
||||
|
|
|
@ -19,6 +19,7 @@ class InstallBackend():
|
|||
def __init__(self, window_main, action):
|
||||
self.window_main = window_main
|
||||
self.action = action
|
||||
self.upgrade_groups_list = ['llllll']
|
||||
|
||||
def start(self,partial_upgrade_list = []):
|
||||
os.environ["APT_LISTCHANGES_FRONTEND"] = "none"
|
||||
|
@ -34,14 +35,14 @@ class InstallBackend():
|
|||
try:
|
||||
#可选升级不为空
|
||||
if partial_upgrade_list:
|
||||
upgrade_groups_list = partial_upgrade_list
|
||||
self.upgrade_groups_list = partial_upgrade_list
|
||||
#全部升级列表
|
||||
else:
|
||||
upgrade_groups_list = self.window_main.update_list.output_upgrade_list.get('upgrade_groups_list',[])
|
||||
self.upgrade_groups_list = self.window_main.update_list.output_upgrade_list.get('upgrade_groups_list',[])
|
||||
|
||||
#遍历升级组列表
|
||||
if upgrade_groups_list:
|
||||
for group_name in upgrade_groups_list:
|
||||
if self.upgrade_groups_list:
|
||||
for group_name in self.upgrade_groups_list:
|
||||
pkgs_install += self.window_main.update_list.output_upgrade_list.get(group_name,[]).get('pkgs_install',[])
|
||||
pkgs_upgrade += self.window_main.update_list.output_upgrade_list.get(group_name,[]).get('pkgs_upgrade',[])
|
||||
|
||||
|
|
Loading…
Reference in New Issue