读取yaml文件生成changelog信息,写入JSON组中 和 修改部分逻辑错误返回
This commit is contained in:
parent
f2192c289a
commit
f7713390a2
|
@ -37,7 +37,7 @@ import random
|
|||
import glob
|
||||
import json
|
||||
from gi.repository import Gio
|
||||
|
||||
import yaml
|
||||
from SystemUpdater.Core import utils
|
||||
from SystemUpdater.Core import filter
|
||||
|
||||
|
@ -513,12 +513,12 @@ class UpdateList():
|
|||
group_important_list.append(pkg_name)
|
||||
|
||||
logging.info("pkg_important_list: %a, group_important_list:%a",pkg_important_list,group_important_list)
|
||||
return True,group_important_list,pkg_important_list
|
||||
return True,group_important_list,pkg_important_list,header,desc
|
||||
except Exception as e:
|
||||
header = _("read important list failed")
|
||||
desc = ("%s",str(e))
|
||||
desc = str(e)
|
||||
logging.error(header + desc)
|
||||
return False,[],[]
|
||||
return False,group_important_list,pkg_important_list,header,desc
|
||||
|
||||
def _make_pkg_info_json(self,cache,pkgs_list):
|
||||
total_download_size = 0
|
||||
|
@ -561,7 +561,7 @@ class UpdateList():
|
|||
# logging.info("this package(%s) not in list ",pkg_name)
|
||||
return new_pkgs_list
|
||||
|
||||
def _make_group_output_json(self,data,upgrade_pkgs_json,install_pkgs_json,hold_pkgs_list,remove_pkgs_list):
|
||||
def _make_group_output_json(self,data,data_yaml,upgrade_pkgs_json,install_pkgs_json):
|
||||
groups_base_info = {}
|
||||
output_json = {}
|
||||
|
||||
|
@ -574,13 +574,16 @@ class UpdateList():
|
|||
groups_base_info.update({"name":data['name']})
|
||||
groups_base_info.update({"description":data['description']})
|
||||
groups_base_info.update({"icon":data['icon']})
|
||||
|
||||
#添加读yaml文件
|
||||
groups_base_info.update({"changelog":data_yaml['changelog']})
|
||||
|
||||
#5、添加升级的内容
|
||||
output_json.update(groups_base_info)
|
||||
output_json.update({"upgrade_list":upgrade_pkgs_json})
|
||||
output_json.update({"install_list":install_pkgs_json})
|
||||
output_json.update({"hold_list":hold_pkgs_list})
|
||||
output_json.update({"remove_list":remove_pkgs_list})
|
||||
# output_json.update({"hold_list":hold_pkgs_list})
|
||||
# output_json.update({"remove_list":remove_pkgs_list})
|
||||
|
||||
#6 产生JSON文件
|
||||
with open(output_config_name, 'w', encoding='utf-8') as f:
|
||||
|
@ -592,22 +595,35 @@ class UpdateList():
|
|||
files = os.listdir(self.INPUT_CONFIG_PATH) #获得文件夹中所有文件的名称列表
|
||||
upgrade_groups_list = []
|
||||
|
||||
for file in files:
|
||||
for ifile in files:
|
||||
#判是否是目录以及是否以JSON结尾
|
||||
if file.endswith('.json'):
|
||||
with open(self.INPUT_CONFIG_PATH+"/"+file,'r') as f:
|
||||
data = json.load(f)
|
||||
if ifile.endswith('.json'):
|
||||
#读取组JSON文件
|
||||
with open(self.INPUT_CONFIG_PATH+"/"+ifile,'r') as f:
|
||||
try:
|
||||
data = json.load(f)
|
||||
except json.JSONDecodeError as exc:
|
||||
logging.error(exc)
|
||||
continue
|
||||
|
||||
group_name = data['package']
|
||||
#读取组的yaml 文件的changelog的信息
|
||||
with open(self.INPUT_CONFIG_PATH + "/" + group_name + ".yaml", "r") as stream:
|
||||
try:
|
||||
data_yaml = yaml.safe_load(stream)
|
||||
except yaml.YAMLError as exc:
|
||||
logging.error(exc)
|
||||
continue
|
||||
|
||||
#过滤没有推送的配置文件
|
||||
if not group_name in group_list:
|
||||
continue
|
||||
|
||||
upgrade_pkgs_list = data['upgrade_list']
|
||||
hold_pkgs_list = data['hold_list']
|
||||
# hold_pkgs_list = data['hold_list']
|
||||
|
||||
#这个安装升级列表中包含当前系统的cache中没有的包 需要过滤
|
||||
remove_pkgs_list = data['remove_list']
|
||||
# remove_pkgs_list = data['remove_list']
|
||||
|
||||
#检查包是否在cache中 以及是否已经安装 没有安装的话才添加到列表
|
||||
new_install_pkgs_list = self._check_pkg_in_cache(cache,data['install_list'])
|
||||
|
@ -630,7 +646,7 @@ class UpdateList():
|
|||
install_pkgs_json = self._make_pkg_info_json(cache,new_install_pkgs_list)
|
||||
|
||||
#输出JSON配置文件
|
||||
self._make_group_output_json(data,upgrade_pkgs_json,install_pkgs_json,hold_pkgs_list,remove_pkgs_list)
|
||||
self._make_group_output_json(data,data_yaml,upgrade_pkgs_json,install_pkgs_json)
|
||||
|
||||
upgrade_groups_list.append(group_name)
|
||||
|
||||
|
@ -681,16 +697,20 @@ class UpdateList():
|
|||
# fu = filter.UpdateListFilterCache()
|
||||
# allowed_origin_upgrade_pkgs = fu.check_in_allowed_origin(pkgs_upgrade)
|
||||
|
||||
success,group_important_list,pkg_important_list = self._read_important_list(cache,pkgs_upgrade)
|
||||
success,group_important_list,pkg_important_list,header,desc = self._read_important_list(cache,pkgs_upgrade)
|
||||
|
||||
#important_list 为空时此次不需要升级
|
||||
if not group_important_list and not pkg_important_list:
|
||||
if success == True and not group_important_list and not pkg_important_list:
|
||||
#不需要升级 全部的软件都是新的
|
||||
header = _("No software updates are available.")
|
||||
desc = _('important_list is Empty')
|
||||
return True,header,desc
|
||||
|
||||
self._make_groups_upgrade(cache,group_list = group_important_list,pkgs_upgrade = ([pkg.name for pkg in pkgs_upgrade]))
|
||||
elif success == False:
|
||||
return False,header,desc
|
||||
|
||||
#分组的包的JSON
|
||||
self._make_groups_upgrade(cache,group_important_list,[pkg.name for pkg in pkgs_upgrade])
|
||||
#产生单包的JSON
|
||||
self._make_single_upgrade(cache,pkg_important_list)
|
||||
|
||||
#是否存在可升级的组
|
||||
|
|
|
@ -77,8 +77,10 @@ class InstallBackend():
|
|||
|
||||
for pkg in pkgs_upgrade:
|
||||
self.window_main.cache[pkg].mark_upgrade()
|
||||
#会安装新包和卸载包
|
||||
Fix.resolve()
|
||||
|
||||
#不会安装和卸载 只升级
|
||||
# Fix.resolve_by_keep()
|
||||
logging.info("Complete calculation of dependencies...")
|
||||
|
||||
new_pkgs_install = []
|
||||
|
|
Loading…
Reference in New Issue