增加状态中文名

增加分组changelog
This commit is contained in:
luoxueyi 2022-07-29 17:24:02 +08:00
parent fe55a422e4
commit f05ae6dce3
2 changed files with 38 additions and 13 deletions

View File

@ -4,6 +4,7 @@ from math import log10
import os
import re
import json
import yaml
import shutil
import sqlite3
import logging
@ -152,9 +153,9 @@ class Sqlite3Server(object):
logging.info(_("Inserting data into the database... "))
try:
self.cursor.execute(
"insert into updateinfos (appname, version, description, date, status, keyword, errorcode, appname_cn) values(?,"
"?,?,?,?,?,?,?)",
(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]))
"insert into updateinfos (appname, version, description, date, status, keyword, errorcode, appname_cn, status_cn, changelog) values(?,"
"?,?,?,?,?,?,?,?,?)",
(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9]))
self.connect.commit()
except Exception as e:
logging.error("Insert error: %s.", str(e))
@ -164,6 +165,7 @@ class Sqlite3Server(object):
def insert_info(self, mode, pkg_list=[], pkg_group=[], adjust_pkg=[], success = False, error_string = '', error_desc = ''):
errstr = error_string + " " + error_desc
status = " "
status_cn = " "
appname_cn = ""
UpdateInfos = {}
InstallInfos = {}
@ -179,8 +181,11 @@ class Sqlite3Server(object):
if success:
status = 'success'
status_cn = '成功'
else:
status = 'failed'
status_cn = '失败'
changeLog = ""
# 判断更新方式
if mode == InstallBackend.MODE_INSTALL_PARTIAL: # 部分更新
pkg_adj = ""
@ -214,7 +219,14 @@ class Sqlite3Server(object):
#FIXME: 临时方案 PHP
PHPSeverSend(_send_log = self.window_main.configs_uncover.getWithDefault("SystemStatus", "upload_upgrade_log", False), _appname=pkgname, _appversion=pkgversion, _statue=status, _errorcode="10000100")
with open(self.window_main.config_path + str(pkgname) + ".yaml", "r") as stream:
try:
data_yaml = yaml.safe_load(stream)
changeLog = data_yaml['changelog']
except yaml.YAMLError as exc:
logging.error(exc)
elif pkg_list:
changeLog = " "
# 单包更新 # 获取单包数据插入数据库
pkgname = pkg_list.pop(0)
for adj in adjust_pkg:
@ -264,18 +276,19 @@ class Sqlite3Server(object):
#FIXME: 临时方案 PHP
PHPSeverSend(_send_log = self.window_main.configs_uncover.getWithDefault("SystemStatus", "upload_upgrade_log", False), _appname=pkgname, _appversion=pkgversion, _statue=status, _errorcode="10000100")
try:
self.insert_into_updateinfo(pkgname, pkgversion, pkgdescription, timestr, status, "1", errstr, appname_cn)
self.insert_into_updateinfo(pkgname, pkgversion, pkgdescription, timestr, status, "1", errstr, appname_cn, status_cn, changeLog)
# FIXME: 发送插入数据库成功的信号local_upgrade_list
self.window_main.dbusController.UpdateSqlitSingle(pkgname, timestr)
# 数据库文件被删除或者新增字段导致需要重新初始化数据库再写入
except Exception as e:
self.init_sqlit()
self.insert_into_updateinfo(pkgname, pkgversion, pkgdescription, timestr, status, "1", errstr, appname_cn)
self.insert_into_updateinfo(pkgname, pkgversion, pkgdescription, timestr, status, "1", errstr, appname_cn, status_cn, changeLog)
# FIXME: 这里也需要, 发送插入数据库成功的信号
self.window_main.dbusController.UpdateSqlitSingle(pkgname, timestr)
elif mode == InstallBackend.MODE_INSTALL_ALL: # 系统全部升级
# # insert signal deb first
for i in pkg_list:
changeLog = ""
try:
pkg = self.window_main.cache[i]
except Exception as e:
@ -307,12 +320,12 @@ class Sqlite3Server(object):
try:
# 软件商店获取中文名
appname_cn = self.get_cn_appname(str(i))
self.insert_into_updateinfo(str(i), pkgversion, pkgdescription, timestr, status, "1", errstr, appname_cn)
self.insert_into_updateinfo(str(i), pkgversion, pkgdescription, timestr, status, "1", errstr, appname_cn, status_cn, changeLog)
self.window_main.dbusController.UpdateSqlitSingle(str(i), timestr)
# 数据库文件被删除或者新增字段导致需要重新初始化数据库再写入
except Exception as e:
self.init_sqlit()
self.insert_into_updateinfo(str(i), pkgversion, pkgdescription, timestr, status, "1", errstr, appname_cn)
self.insert_into_updateinfo(str(i), pkgversion, pkgdescription, timestr, status, "1", errstr, appname_cn, status_cn, changeLog)
self.window_main.dbusController.UpdateSqlitSingle(str(i), timestr)
#FIXME: 临时方案 PHP
PHPSeverSend(_send_log = self.window_main.configs_uncover.getWithDefault("SystemStatus", "upload_upgrade_log", False), _appname=pkg.name, _appversion=pkgversion, _statue=status, _errorcode="10000100")
@ -338,13 +351,20 @@ class Sqlite3Server(object):
self.window_main.collector.Upgrade_Process_Msg("finish-install", InstallInfos.copy())
#FIXME: 临时方案 PHP
PHPSeverSend(_send_log = self.window_main.configs_uncover.getWithDefault("SystemStatus", "upload_upgrade_log", False), _appname=i, _appversion=pkgversion, _statue=status, _errorcode="10000100")
with open(self.window_main.config_path + str(i) + ".yaml", "r") as stream:
try:
data_yaml = yaml.safe_load(stream)
changeLog = data_yaml['changelog']
except yaml.YAMLError as exc:
logging.error(exc)
try:
self.insert_into_updateinfo(str(i), pkgversion, pkgdescription, timestr, status, "1", errstr, appname_cn)
self.insert_into_updateinfo(str(i), pkgversion, pkgdescription, timestr, status, "1", errstr, appname_cn, status_cn, changeLog)
self.window_main.dbusController.UpdateSqlitSingle(str(i), timestr)
# 数据库文件被删除或者新增字段导致需要重新初始化数据库再写入
except Exception as e:
self.init_sqlit()
self.insert_into_updateinfo(str(i), pkgversion, pkgdescription, timestr, status, "1", errstr, appname_cn)
self.insert_into_updateinfo(str(i), pkgversion, pkgdescription, timestr, status, "1", errstr, appname_cn, status_cn, changeLog)
self.window_main.dbusController.UpdateSqlitSingle(str(i), timestr)
# 系统升级完成 ..判断版本号
@ -353,7 +373,7 @@ class Sqlite3Server(object):
self._refresh_system_version(str(pkgversion))
elif mode == InstallBackend.MODE_INSTALL_SYSTEM: # 全盘升级
self.insert_into_updateinfo(str("Upgrade System"), "", "This is a complete system upgrade, equivalent to the implementation of apt dist-upgrade", timestr, status, "1", errstr, str("全盘升级"))
self.insert_into_updateinfo(str("Upgrade System"), "", "This is a complete system upgrade, equivalent to the implementation of apt dist-upgrade", timestr, status, "1", errstr, str("全盘升级"), status_cn, " ")
self.window_main.dbusController.UpdateSqlitSingle(str("Upgrade System"), timestr)
# 全盘更新完成 ..判断版本号
if status == "success":
@ -538,21 +558,24 @@ class Sqlite3Server(object):
upgrade_info[str(it)] = str(args[str(it)])
logging.info("upgrade_info: %s", upgrade_info)
#self.insert_into_updateinfo(str(i), pkgversion, pkgdescription, timestr, status, "1", errstr, appname_cn)
if "appname" in upgrade_info.keys() and "version" in upgrade_info.keys() \
and "description" in upgrade_info.keys() \
and "date" in upgrade_info.keys() \
and "status" in upgrade_info.keys() \
and "keyword" in upgrade_info.keys() \
and "errorcode" in upgrade_info.keys() \
and "appname_cn" in upgrade_info.keys() :
and "appname_cn" in upgrade_info.keys() \
and "status_cn" in upgrade_info.keys() \
and "changelog" in upgrade_info.keys():
self.insert_into_updateinfo( upgrade_info["appname"], upgrade_info["version"], \
upgrade_info["description"], \
upgrade_info["date"], \
upgrade_info["status"], \
upgrade_info["keyword"], \
upgrade_info["errorcode"], \
upgrade_info["appname_cn"] )
upgrade_info["appname_cn"], \
upgrade_info["status_cn"], \
upgrade_info["changelog"] )
except Exception as e:
logging.error(e)
return False

2
debian/postinst vendored
View File

@ -18,4 +18,6 @@ if [ -f /usr/share/kylin-system-updater/SystemUpdater/Core/DataMigration.py ];th
# /usr/share/kylin-system-updater/SystemUpdater/Core/DataMigration.py -m
/usr/share/kylin-system-updater/SystemUpdater/Core/DataMigration.py -u appname_cn=
/usr/share/kylin-system-updater/SystemUpdater/Core/DataMigration.py -t=tid_search
/usr/share/kylin-system-updater/SystemUpdater/Core/DataMigration.py -u status_cn=
/usr/share/kylin-system-updater/SystemUpdater/Core/DataMigration.py -u changelog=
fi