调整部分代码逻辑

This commit is contained in:
wangsong 2021-09-29 11:02:56 +08:00
parent 14c69c923a
commit fa2272bd33
3 changed files with 61 additions and 47 deletions

View File

@ -161,38 +161,10 @@ class UpdateManager():
if os.path.exists(REBOOT_REQUIRED_FILE):
logging.error("REBOOT_REQUIRED_FILE")
def refresh_cache(self):
def check_group_config(self):
_success = True
header = None
desc = None
try:
self.update_list = UpdateList(self)
#第一次进入 之后update不进入
if self.cache is None:
self.cache = MyCache(None)
else:
self.cache.open(None)
self.cache._initDepCache()
except AssertionError:
header = _("Software index is broken")
desc = _("It is impossible to install or remove any software. "
"Please use the package manager \"Synaptic\" or run "
"\"sudo apt-get install -f\" in a terminal to fix "
"this issue at first.")
_success = False
return _success,header,desc
except SystemError as e:
header = _("Could not initialize the package information")
desc = _("An unresolvable problem occurred while "
"initializing the package information.\n\n"
"Please report this bug against the 'update-manager' "
"package and include the following error "
"message:\n") + str(e)
_success = False
return _success,header,desc
#2、 安装JSON分组配置文件包 安装完毕会重新调start_available --> here 安装失败就直接退出不会进行下面的操作
try:
pkg_json = self.cache[self.update_list.GROUPS_JSON_PKG]
@ -243,12 +215,50 @@ class UpdateManager():
logging.info('Emptying the configuration file is complete...')
except Exception as e:
logging.warning(e)
return _success,header,desc
#FIXME: 5、 待开发功能 根据监测存在配置文件 不存在进行重新安装包 再检测还是未存在的话 就判断此次没有可升级的
def refresh_cache(self):
_success = True
header = None
desc = None
try:
self.update_list = UpdateList(self)
#第一次进入 之后update不进入
if self.cache is None:
self.cache = MyCache(None)
else:
self.cache.open(None)
self.cache._initDepCache()
except AssertionError:
header = _("Software index is broken")
desc = _("It is impossible to install or remove any software. "
"Please use the package manager \"Synaptic\" or run "
"\"sudo apt-get install -f\" in a terminal to fix "
"this issue at first.")
_success = False
return _success,header,desc
except SystemError as e:
header = _("Could not initialize the package information")
desc = _("An unresolvable problem occurred while "
"initializing the package information.\n\n"
"Please report this bug against the 'update-manager' "
"package and include the following error "
"message:\n") + str(e)
_success = False
return _success,header,desc
#更新important.list
_success,header,desc = self.dbusController._on_update_important_list()
if _success == False:
return _success,header,desc
#检查更新分组配置表
_success,header,desc = self.check_group_config()
if _success == False:
return _success,header,desc
#FIXME: 6、 出错后未进行处理 更新important.list 文件错误的话
self.dbusController._on_update_important_list()
try:
_success,header,desc = self.update_list.update(self.cache)
except SystemError as e:

View File

@ -4,6 +4,7 @@ import dbus.service
import logging
import threading
from gettext import gettext as _
from .Core.AlertWatcher import AlertWatcher
from .Core.roam import NetworkManagerHelper
from .Core.filter import UpdateListFilterCache as fu
@ -28,6 +29,10 @@ class UpdateManagerDbusController(dbus.service.Object):
#更新important.list的本次升级的列表
def _on_update_important_list(self):
_success = True
header = None
desc = None
lock = threading.Lock()
bus = dbus.SystemBus()
try:
@ -41,11 +46,16 @@ class UpdateManagerDbusController(dbus.service.Object):
return False
if retval == False:
logging.warning("update SourceTemplate failed")
return False
#FIXME: 需要处理返回结果 转化成中文
#获取软件推送失败
#请检查推送服务器
header = _("Get software push failure")
desc = _("Please check the push servers")
logging.warning(header + desc)
return _success,header,desc
else:
logging.info("update sourceTemplate successed...")
return True
return _success,header,desc
#检测网络的状态
def _on_network_alert(self, watcher, state):

View File

@ -9,7 +9,6 @@ from __future__ import absolute_import
import logging
import os
from gettext import gettext as _
from SystemUpdater.Core import Database
import apt_pkg
@ -69,6 +68,7 @@ class InstallBackend():
logging.info("ProblemResolver install:%d , upgrade:%d",len(pkgs_install),len(pkgs_upgrade))
logging.info("Start calculating dependencies...")
self.window_main.cache._initDepCache()
Fix = apt_pkg.ProblemResolver(self.window_main.cache._depcache)
@ -105,24 +105,18 @@ class InstallBackend():
logging.error(e)
def start(self,partial_upgrade_list = []):
#FIXME: 在下载升级的能抑制系统关闭或者睡眠 参考ubuntu此部分代码
if self.action == self.ACTION_INSTALL:
pkgs_install = []
pkgs_upgrade = []
pkgs_remove = []
pkgs_purge = []
pkgs_install,pkgs_upgrade,pkgs_remove = self._make_problem_resolver(partial_upgrade_list)
try:
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)
self.commit(pkgs_install, pkgs_upgrade, pkgs_remove)
except Exception as e:
logging.error(e)
else:
self.update()
self.update()
#调用此接口进行安装升级包的话,安装完成或者升级完成会重新调用升级
def start_alone(self,pkgs_install = [], pkgs_upgrade = [], pkgs_remove = [],pkgs_purge = []):
os.environ["APT_LISTCHANGES_FRONTEND"] = "none"
@ -137,7 +131,7 @@ class InstallBackend():
"""Run a update to refresh the package list"""
raise NotImplementedError
def commit(self, pkgs_install, pkgs_upgrade, pkgs_remove,pkgs_purge):
def commit(self, pkgs_install, pkgs_upgrade, pkgs_remove,pkgs_purge = []):
"""Commit the cache changes """
raise NotImplementedError