This commit is contained in:
luoxueyi 2021-11-16 14:36:22 +08:00
commit 0cd3f37139
4 changed files with 58 additions and 6 deletions

View File

@ -65,6 +65,14 @@ class UpdateManager():
except KeyboardInterrupt:
self.dbusController.Quit(None)
#进行清空所有下载的文件
def start_clean(self):
try:
clean_backend = get_backend(self, InstallBackend.ACTION_CLEAN)
clean_backend.start()
except Exception as e:
logging.error(e)
#进行升级的操作
def start_fix_broken(self):
try:

View File

@ -124,16 +124,32 @@ class UpdateManagerDbusController(dbus.service.Object):
mainloop.quit()
logging.debug("Exit")
#Remove all downloaded files.
@dbus.service.method(UPDATER_DBUS_INTERFACE,out_signature='b')
def Clean(self):
try:
#处于更新和升级中的话 不进行更新
if self.parent.is_working != InstallBackend.ACTION_DEFUALT_STATUS:
logging.warning('Clean In the process of updating or Upgrading...')
return False,'In the process of updating or Upgrading...'
else:
self.parent.start_clean()
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' Clean ...')
return True
except Exception:
return False
#获取后端现在的状态
@dbus.service.method(UPDATER_DBUS_INTERFACE,out_signature='i')
def GetBackendStatus(self):
try:
#处于更新和升级中的话 不进行更新
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' GetBackendStatus ...')
return self.parent.is_working
except Exception:
return False
#更新的dbus
#更新的dbus apt install -f
@dbus.service.method(UPDATER_DBUS_INTERFACE,out_signature='b')
def FixBrokenDepends(self):
try:
@ -153,7 +169,7 @@ class UpdateManagerDbusController(dbus.service.Object):
def FixIncompleteInstall(self):
try:
#处于更新和升级中的话 不进行更新
if self.parent.is_working:
if self.parent.is_working != InstallBackend.ACTION_DEFUALT_STATUS:
logging.warning('FixIncompleteInstall In the process of updating or Upgrading...')
return False,'In the process of updating or Upgrading...'
else:

View File

@ -181,6 +181,25 @@ class InstallBackendAptdaemon(InstallBackend):
error_string='', error_desc='')
raise
@inline_callbacks
def clean(self):
"""清空所有下载的文件 """
try:
trans = yield self.client.clean(defer=True)
self.window_main.dbusController.transaction = trans
# 注册回调函数 接收更新的状态
yield self._show_transaction(trans, self.ACTION_CLEAN,
_("Remove all downloaded files."), False)
except errors.NotAuthorizedError:
self._action_done(self.ACTION_CLEAN,
authorized=False, success=False,
error_string='', error_desc='')
except Exception:
self._action_done(self.ACTION_CLEAN,
authorized=True, success=False,
error_string='', error_desc='')
raise
@inline_callbacks
def download_deb(self, pkg_lists):
"""download deb only"""
@ -248,9 +267,10 @@ class InstallBackendAptdaemon(InstallBackend):
#此处发不发信号一样 频率很低
self.window_main.dbusController.UpdateDloadAndInstStaChanged(upgrade_content,progress,status,details)
elif action == self.ACTION_FIX_BROKEN:
self.window_main.dbusController.FixBrokenStatusChanged(progress,status)
# elif action == self.ACTION_FIX_BROKEN:
# self.window_main.dbusController.FixBrokenStatusChanged(progress,status)
else:
logging.info("Other Action:progress = %d , status = %s ,details = %s",progress,status,details)
def _on_details_changed(self, trans, details):
self.details = details

View File

@ -47,6 +47,7 @@ class InstallBackend():
ACTION_FIX_BROKEN = 5
ACTION_REMOVE_PACKAGES = 6
ACTION_FIX_INCOMPLETE = 7
ACTION_CLEAN = 8
def __init__(self, window_main, action):
self.window_main = window_main
@ -85,7 +86,7 @@ class InstallBackend():
#检查磁盘的状态
_success,desc = check_free_space(self.cache)
if _success == False and desc != None:
if _success == False:
header = _("Disk space is insufficient, please clean the disk and then upgrade")
self._action_done(self.action,True,False,header,desc)
return
@ -151,6 +152,9 @@ class InstallBackend():
#卸载包
elif self.action == self.ACTION_REMOVE_PACKAGES:
self.purge_packages(partial_upgrade_list)
#清空所有下载的文件
elif self.action == self.ACTION_CLEAN:
self.clean()
#更新cache
elif self.action == self.ACTION_UPDATE:
self.update()
@ -173,6 +177,10 @@ class InstallBackend():
"""Run a update to refresh the package list"""
raise NotImplementedError
def clean(self):
"""Remove all downloaded files.t"""
raise NotImplementedError
def commit(self, pkgs_install, pkgs_upgrade, pkgs_remove,pkgs_purge = []):
"""Commit the cache changes """
raise NotImplementedError