修改打印日志,完善报错日志,源过滤出错时,不进行原过滤

This commit is contained in:
wangsong 2021-12-08 14:24:18 +08:00
parent cda014319a
commit 88fd3e5fae
3 changed files with 31 additions and 12 deletions

View File

@ -122,7 +122,7 @@ class UpdateList():
with open(IMPORTANT_LIST_PATH, 'r') as f:
data = f.read()
important_list = data.split()
logging.info("important_list: %a",important_list)
logging.info("The Server Push List: %a",important_list)
for pkg_name in important_list:
#检查是否在cache 没有在cache中属于组
@ -142,7 +142,7 @@ class UpdateList():
install_list,upgrade_list = self._make_fiter_origin(pkg_list,True)
pkg_important_list = install_list + upgrade_list
logging.info("pkg_important_list: %a, group_important_list:%a",pkg_important_list,group_important_list)
logging.info("Push Single Packages: %a, Push Groups:%a",pkg_important_list,group_important_list)
return True,group_important_list,pkg_important_list,header,desc
except Exception as e:
header = _("read important list failed")
@ -221,14 +221,24 @@ class UpdateList():
logging.info("Generate Jsonfile(%s) to complete... ",output_config_name)
#进行源过滤is_adjust 是否调整cache中的候选版本单包推送会调整保持控制面板显示正确的版本
def _make_fiter_origin(self,all_pkg_obj,is_adjust):
def _make_fiter_origin(self,_all_pkg_obj,is_adjust):
new_install_list = []
new_upgrade_list = []
adjust_pkgs = []
all_pkg_obj = []
#是否进行源过滤的选项
if self.is_close_filter == False:
all_pkg_obj,adjust_pkgs = self.fu.check_in_allowed_origin(all_pkg_obj,is_adjust)
try:
all_pkg_obj,adjust_pkgs = self.fu.check_in_allowed_origin(_all_pkg_obj,is_adjust)
except Exception as e:
all_pkg_obj = _all_pkg_obj
adjust_pkgs = []
logging.error("Check Allowed origin is occur error:" + str(e))
logging.error("Close to Allowed origin fiter...")
else:
all_pkg_obj = _all_pkg_obj
adjust_pkgs = []
self.local_upgrade_data.adjust_pkgs += adjust_pkgs

View File

@ -306,7 +306,7 @@ class UpdateManager():
pkg_json = cache[self.SELF_PKG_NAME]
#是否安装
if pkg_json.is_installed and pkg_json.is_upgradable:
logging.info("Self-Updater(%s) start upgrading...",self.SELF_PKG_NAME)
logging.info("Check: Self-Updater(%s) start upgrading...",self.SELF_PKG_NAME)
pkg_json.mark_upgrade()
self.start_install(InstallBackend.MODE_UPGRADE_SINGLE,True)
@ -315,13 +315,13 @@ class UpdateManager():
header = self.INSTALL_ALONE_PROGRESS
return _success,header,desc
else:
logging.info("Self-Updater(%s) No need to upgrade...",self.SELF_PKG_NAME)
logging.info("Check: Self-Updater(%s) No need to upgrade...",self.SELF_PKG_NAME)
#直接退出 进行之后的动作
_success = True
return _success,header,desc
else:
#没有在cache中就认为不需要升级
logging.error("Self-Updater(%s) The upgrade package is not in Cache...",self.SELF_PKG_NAME)
logging.error("Check: Self-Updater(%s) The upgrade package is not in Cache...",self.SELF_PKG_NAME)
#直接退出 进行之后的动作
_success = True
return _success,header,desc
@ -344,7 +344,7 @@ class UpdateManager():
if pkg_json.is_installed:
#是否可升级
if pkg_json.is_upgradable:
logging.info("groups JSON ConfigPkgs(%s) start upgrading...",self.GROUPS_PKG_NAME)
logging.info("Check: groups JSON ConfigPkgs(%s) start upgrading...",self.GROUPS_PKG_NAME)
pkg_json.mark_upgrade()
self.start_install(InstallBackend.MODE_UPGRADE_SINGLE,True)
@ -353,9 +353,9 @@ class UpdateManager():
header = self.INSTALL_ALONE_PROGRESS
return _success,header,desc
else:
logging.info("ConfigPkgs(%s) No need to upgrade...",self.GROUPS_PKG_NAME)
logging.info("Check: ConfigPkgs(%s) No need to upgrade...",self.GROUPS_PKG_NAME)
else:
logging.info("groups JSON ConfigPkgs(%s) start new installing...",self.GROUPS_PKG_NAME)
logging.info("Check: groups JSON ConfigPkgs(%s) start new installing...",self.GROUPS_PKG_NAME)
pkg_json.mark_install()
self.start_install(InstallBackend.MODE_UPGRADE_SINGLE,True)
#直接退出
@ -365,7 +365,7 @@ class UpdateManager():
else:
header = _("Unable to get group configuration package, please contact administrator to solve")
desc = _("groups JSON ConfigPkgs install failed")
logging.error("groups JSON ConfigPkgs(%s) install failed...",self.GROUPS_PKG_NAME)
logging.error("Check: groups JSON ConfigPkgs(%s) install failed...",self.GROUPS_PKG_NAME)
_success = False
return _success,header,desc
@ -394,6 +394,8 @@ class UpdateManager():
"var/run/reboot-required"))
def _check_cache_broken(self,cache):
logging.info("Check: System Apt Cache for Broken...")
with cache.actiongroup():
if cache.get_changes():
cache.clear()

View File

@ -264,6 +264,12 @@ class InstallBackendAptdaemon(InstallBackend):
#不要101这种未知状态
if progress == 101:
return
#过滤掉不是线性的进度
if progress > self.trans_progress:
self.trans_progress = progress
else:
return
self.trans_progress = progress
self._dist_status_changed(action,self.now_upgrade.upgrade_groups+self.now_upgrade.single_pkgs,\
@ -330,7 +336,8 @@ class InstallBackendAptdaemon(InstallBackend):
humanize_size(current_cps))
def _on_cancellable_changed(self, trans, Cancelable):
if self.action == self.ACTION_REMOVE_PACKAGES:
#下面的这些 不发送取消信号
if self.action == self.ACTION_REMOVE_PACKAGES or self.action == self.ACTION_UPDATE:
return
logging.info("\033[43;1m" + "emit" + "\033[0m" +" Cancelable: %r",Cancelable)