调整部分代码

This commit is contained in:
wangsong 2021-09-29 11:11:00 +08:00
parent b730bf1e59
commit 04f6cc12f1
3 changed files with 12 additions and 12 deletions

View File

@ -213,7 +213,6 @@ class UpdateList():
self.random = random.Random()
#FIXME: 最好将这个常量通过配置文件读
self.GROUPS_JSON_PKG = 'kylin-update-desktop-config'
self.INPUT_CONFIG_PATH = '/usr/share/kylin-update-desktop-config/data'
self.OUTPUT_CONFIG_PATH = '/var/lib/kylin-system-upgrade'

View File

@ -32,6 +32,7 @@ warnings.filterwarnings("ignore", "Accessed deprecated property",
#安装完成之后是否有请求需要重启
REBOOT_REQUIRED_FILE = "/var/run/reboot-required"
GROUPS_JSON_PKG = 'kylin-update-desktop-config'
INSTALL_ALONE_PROGRESS = "alone"
class UpdateManager():
@ -161,28 +162,28 @@ class UpdateManager():
if os.path.exists(REBOOT_REQUIRED_FILE):
logging.error("REBOOT_REQUIRED_FILE")
def check_group_config(self):
def check_group_config(self,cache):
_success = True
header = None
desc = None
#2、 安装JSON分组配置文件包 安装完毕会重新调start_available --> here 安装失败就直接退出不会进行下面的操作
try:
pkg_json = self.cache[self.update_list.GROUPS_JSON_PKG]
pkg_json = cache[GROUPS_JSON_PKG]
#是否安装
if pkg_json.is_installed:
#是否可升级
if pkg_json.is_upgradable:
logging.info("groups JSON ConfigPkgs(%s) start upgrading...",self.GROUPS_JSON_PKG)
self.start_install_alone(pkgs_upgrade = [self.update_list.GROUPS_JSON_PKG])
self.start_install_alone(pkgs_upgrade = [GROUPS_JSON_PKG])
#直接退出
_success = True
header = INSTALL_ALONE_PROGRESS
return _success,header,desc
else:
logging.info("ConfigPkgs(%s) No need to upgrade...",self.update_list.GROUPS_JSON_PKG)
logging.info("ConfigPkgs(%s) No need to upgrade...",GROUPS_JSON_PKG)
else:
logging.info("groups JSON ConfigPkgs(%s) start new installing...",self.update_list.GROUPS_JSON_PKG)
self.start_install_alone(pkgs_install = [self.update_list.GROUPS_JSON_PKG])
logging.info("groups JSON ConfigPkgs(%s) start new installing...",GROUPS_JSON_PKG)
self.start_install_alone(pkgs_install = [GROUPS_JSON_PKG])
#直接退出
_success = True
header = INSTALL_ALONE_PROGRESS
@ -190,7 +191,7 @@ class UpdateManager():
#FIXME: 错误处理未做 报告到控制面板
except Exception as e:
logging.warning("groups JSON ConfigPkgs(%s) install failed...",self.update_list.GROUPS_JSON_PKG)
logging.warning("groups JSON ConfigPkgs(%s) install failed...",GROUPS_JSON_PKG)
logging.error(e)
_success = False
@ -198,7 +199,7 @@ class UpdateManager():
if not os.path.exists(self.update_list.INPUT_CONFIG_PATH):
logging.info("groups JSON Config Path(%s) Missing and Trying to fix...",self.update_list.INPUT_CONFIG_PATH)
#将软件包卸载 之后进行重新安装here --> purge --> start_available 进行判断是否安装未安装重新安装
self.start_install_alone(pkgs_purge = [self.update_list.GROUPS_JSON_PKG])
self.start_install_alone(pkgs_purge = [GROUPS_JSON_PKG])
#直接退出
_success = True
header = INSTALL_ALONE_PROGRESS
@ -255,7 +256,7 @@ class UpdateManager():
return _success,header,desc
#检查更新分组配置表
_success,header,desc = self.check_group_config()
_success,header,desc = self.check_group_config(self.cache)
if _success == False:
return _success,header,desc

View File

@ -6,6 +6,7 @@ from aptdaemon import client, errors
from defer import inline_callbacks
from aptdaemon.enums import (EXIT_SUCCESS,
EXIT_FAILED,
EXIT_CANCELLED,
get_error_description_from_enum,
get_error_string_from_enum,
get_status_string_from_enum
@ -50,7 +51,7 @@ class InstallBackendAptdaemon(InstallBackend):
raise
@inline_callbacks
def commit(self, pkgs_install, pkgs_upgrade, pkgs_remove,pkgs_purge):
def commit(self, pkgs_install, pkgs_upgrade, pkgs_remove,pkgs_purge = []):
"""Commit a list of package adds and removes"""
try:
reinstall = downgrade = []
@ -102,7 +103,6 @@ class InstallBackendAptdaemon(InstallBackend):
def _on_details_changed(self, trans, details):
self.details = details
# logging.info("details: %s", details)
def _on_download_changed(self, trans, details):
logging.info(details)