增加部分升级模式和全部升级模式的dbus接口

This commit is contained in:
wangsong 2021-09-13 11:36:44 +08:00
parent 96cfc85d62
commit 4ebceaaabb
4 changed files with 36 additions and 23 deletions

View File

@ -105,10 +105,12 @@ class UpdateManager():
#进行更新的操作
def start_update(self):
self.is_updating = True
update_backend = get_backend(self, InstallBackend.ACTION_UPDATE)
update_backend.start()
try:
self.is_updating = True
update_backend = get_backend(self, InstallBackend.ACTION_UPDATE)
update_backend.start()
except Exception as e:
logging.error(e)
#进行升级的操作
def start_install(self,partial_upgrade_list = []):
@ -116,10 +118,13 @@ class UpdateManager():
#检查磁盘的状态
# if self.check_free_space(self.cache) == False:
# return
try:
self.is_upgrading = True
install_backend = get_backend(self, InstallBackend.ACTION_INSTALL)
install_backend.start(partial_upgrade_list=partial_upgrade_list)
except Exception as e:
logging.error(e)
self.is_upgrading = True
install_backend = get_backend(self, InstallBackend.ACTION_INSTALL)
install_backend.start(partial_upgrade_list)
#进行升级的操作-传入包列表
def start_install_alone(self,pkgs_install = [], pkgs_upgrade = [], pkgs_remove = [],pkgs_purge = []):

View File

@ -79,30 +79,35 @@ class UpdateManagerDbusController(dbus.service.Object):
logging.info('In the process of updating or Upgrading...')
return False,'In the process of updating or Upgrading...'
else:
self.parent.start_install()
logging.info('dbus upgrading ...')
self.parent.start_install()
return True
except Exception:
return False
#部分升级
@dbus.service.method(INTERFACE,in_signature='as',out_signature='b')
def partial_upgrade(self,upgrade_list):
@dbus.service.method(INTERFACE,in_signature='as',out_signature='bs')
def partial_upgrade(self,_partial_upgrade_list):
try:
#处于更新和升级中的话 不进行升级
if self.parent.is_updating or self.parent.is_upgrading:
logging.info('In the process of updating or Upgrading...')
return False,'In the process of updating or Upgrading...'
else:
#不为空时
partial_upgrade_list = [str(i) for i in _partial_upgrade_list]
#本地维护的可升级的组
upgrade_groups_list = self.parent.update_list.output_upgrade_list.get('upgrade_groups_list',[])
upgrade_list = list(set(partial_upgrade_list) & set(upgrade_groups_list))
if upgrade_list:
logging.info('dbus partial_upgrade(%s)',upgrade_list)
self.parent.start_install(upgrade_list)
logging.info('dbus upgrading ...')
return True,'dbus upgrading ...'
return True,'dbus upgrading'
else:
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,e
return False,'error'
#更新和升级的进度信息 0~100 进度信息 101为非预期的信号
@dbus.service.signal(INTERFACE,signature='is')

View File

@ -110,9 +110,9 @@ 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("progress-details-changed", self._on_progress_download_changed)
# trans.connect("download-changed", self._on_download_changed)

View File

@ -31,13 +31,14 @@ class InstallBackend():
pkgs_upgrade = []
pkgs_remove = []
pkgs_purge = []
try:
upgrade_groups_list = self.window_main.update_list.output_upgrade_list.get('upgrade_groups_list',[])
#当partial_upgrade_list 不为空时为可选升级方式
#可选升级不为空
if partial_upgrade_list:
upgrade_groups_list = list(set(partial_upgrade_list) & set(upgrade_groups_list))
upgrade_groups_list = partial_upgrade_list
#全部升级列表
else:
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:
@ -48,10 +49,12 @@ class InstallBackend():
else:
logging.info("no upgradeable packages")
return
except Exception as e:
logging.error(e)
self.commit(pkgs_install, pkgs_upgrade, pkgs_remove,pkgs_purge)
pass
logging.info("commit install:%d , upgrade:%d remove:%d",len(pkgs_install),len(pkgs_upgrade),len(pkgs_remove))
# self.commit(pkgs_install, pkgs_upgrade, pkgs_remove,pkgs_purge)
else:
self.update()