修复冲突

This commit is contained in:
wangsong 2021-09-13 11:39:34 +08:00
commit 623f01e340
2 changed files with 43 additions and 4 deletions

View File

@ -24,6 +24,7 @@ class UpdateManagerDbusController(dbus.service.Object):
self.alert_watcher.check_alert_state()
self.alert_watcher.connect("network-alert", self._on_network_alert)
self.connected = False
self.transaction = None
#更新important.list的本次升级的列表
def _on_update_important_list(self):
@ -107,7 +108,13 @@ class UpdateManagerDbusController(dbus.service.Object):
logging.info('input upgrade list(%s) not in local upgrade_list(%s)',partial_upgrade_list,upgrade_groups_list)
return False,'upgrade_list is empty'
except Exception as e:
return False,'error'
return False,e
# 取消transaction
@dbus.service.method(INTERFACE, out_signature='b')
def on_cancel_clicked(self):
self.transaction.cancel()
return True
#更新和升级的进度信息 0~100 进度信息 101为非预期的信号
@dbus.service.signal(INTERFACE,signature='is')
@ -116,6 +123,22 @@ class UpdateManagerDbusController(dbus.service.Object):
@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)
logging.info("emit success = %r , upgrade_group = %a, error_string = %s , error_desc = %s ",\
success,upgrade_group, error_string,error_desc)
pass
#发送下载包信息
@dbus.service.signal(INTERFACE, signature='iiiiii')
def on_download_changed_signal(self, 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)
pass
# 信号是否可取消
@dbus.service.signal(INTERFACE, signature='b')
def cancelable(self, cancelable):
logging.info("cancelable: %r",\
cancelable)
pass

View File

@ -38,6 +38,7 @@ class InstallBackendAptdaemon(InstallBackend):
"""刷新包cache"""
try:
trans = yield self.client.update_cache(defer=True)
self.window_main.dbusController.transaction = trans
#注册回调函数 接收更新的状态
yield self._show_transaction(trans, self.ACTION_UPDATE,
_("Checking for updates…"), False)
@ -59,6 +60,7 @@ class InstallBackendAptdaemon(InstallBackend):
trans = yield self.client.commit_packages(
pkgs_install, reinstall, pkgs_remove, purge = pkgs_purge, upgrade = pkgs_upgrade,
downgrade = downgrade, defer=True)
self.window_main.dbusController.transaction = trans
#安装的进度信息
# trans.connect("progress-changed", self._on_progress_changed)
yield self._show_transaction(trans, self.ACTION_INSTALL,
@ -96,7 +98,18 @@ class InstallBackendAptdaemon(InstallBackend):
logging.info(details)
def _on_progress_download_changed(self,trans,current_items, total_items, currenty_bytes, total_bytes, current_cps, eta):
print(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, \
currenty_bytes, total_bytes, \
current_cps, eta)
def _on_cancellable_changed(self, trans, cancelable):
self.window_main.dbusController.cancelable(cancelable)
@inline_callbacks
def _show_transaction(self, trans, action, header, show_details):
@ -110,10 +123,13 @@ class InstallBackendAptdaemon(InstallBackend):
# 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-changed", self._on_progress_changed)
# trans.connect("progress-details-changed", self._on_progress_download_changed)
trans.connect("cancellable-changed", self._on_cancellable_changed)
# trans.connect("download-changed", self._on_download_changed)
# trans.connect("config-file-conflict", self._on_config_file_conflict)