Merge branch 'backend_uu' into uu_test

This commit is contained in:
shenyafeng 2022-10-21 17:31:47 +08:00
commit 541384643e
6 changed files with 49 additions and 16 deletions

View File

@ -114,9 +114,9 @@ class Sqlite3Server(object):
self.connect_database()
self.cursor.execute(
"insert into installed (appname, version, time, description, icon, statue, keyword, errorcode) values(?,"
"?,?,?,?,?,?,?)",
(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]))
"?,?,?,?,?,?,?)", (args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]))
self.connect.commit()
logging.info("Database: Insert (%s=%s) To installed Complete ...", args[0], args[1])
self.disconnect_database()
# 写入数据到display表中
@ -141,6 +141,7 @@ class Sqlite3Server(object):
"insert into tid_search (key, tid) values(?,?)",
(args[0], args[1]))
self.connect.commit()
logging.info("Database: Insert (%s=%s) To tid_search Complete ...", args[0], args[1])
self.disconnect_database()
# 搜索tid_search表获取tid值
@ -158,39 +159,40 @@ class Sqlite3Server(object):
except Exception as e:
logging.error("Insert error: %s.", str(e))
self.disconnect_database()
logging.info(_("Database: Select data Complete..."))
logging.info("Database: Select tid_search data Complete...")
self.disconnect_database()
return retval
# 读出display表中数据
def select_from_display(self, *args, **kwargs):
self.connect_database()
try:
self.connect_database()
sql = "select "+args[0]+" from display"
self.cursor.execute(sql)
self.connect.commit()
retval = str(self.cursor.fetchone()[0])
self.disconnect_database()
return retval
except Exception as e:
logging.error("select error: %s.", str(e))
self.disconnect_database()
return "Error"
logging.info("Database: Search display Complete (%s=%s) ...", args[0], args[1])
self.disconnect_database()
return retval
# 写入updateinfos表中
def insert_into_updateinfo(self, *args, **kwargs):
self.connect_database()
try:
self.connect_database()
self.cursor.execute(
"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()
self.disconnect_database()
except Exception as e:
logging.error("Insert error: %s.", str(e))
self.disconnect_database()
logging.info(_("Database: Insert To Complete..."))
logging.info(_("Database: Insert To updateinfos Complete..."))
self.disconnect_database()
# 接收更新列表与信息,生成数据并插入数据库中
def insert_info(self, mode, pkg_list=[], pkg_group=[], adjust_pkg=[], success = False, error_string = '', error_desc = ''):
@ -485,8 +487,8 @@ class Sqlite3Server(object):
# logging.error("Check update error: %s", str(e))
def _system_version_config(self):
self.connect_database()
try:
self.connect_database()
sql = "select init_version from display where id=1"
self.cursor.execute(sql)
_is_init_verison = self.cursor.fetchone()[0]
@ -497,10 +499,10 @@ class Sqlite3Server(object):
sql = "update display set init_version = 'no'"
self.cursor.execute(sql)
self.connect.commit()
self.disconnect_database()
except Exception as e:
logging.error(str(e))
self.disconnect_database()
self.disconnect_database()
def _refresh_system_version(self, update_version='', os_version = '', pseudo_version = False):
try:

View File

@ -759,8 +759,30 @@ def deb_verify(deb_path, _isinstall = False):
return 3
def PolicyKit_Authority(details = '', sender = None):
_allow_kylinsign = False
_verify_kylinsign = False
try:
#获取未知来源应用安装策略Unknown sources apply installation policies
inst_policies_path = "/etc/dpkg/dpkg.cfg"
if os.path.isfile(inst_policies_path):
with open(inst_policies_path, "r") as f:
lines = f.readlines()
for line in lines:
if "allow-kylinsign" in line:
_allow_kylinsign = True
if "verify-kylinsign" in line:
_verify_kylinsign = True
if _allow_kylinsign == True and _verify_kylinsign == False: #策略: 阻止
logging.debug("unknown sources apply installation policies: deter")
return False,_("The package is unsigned, refuses to install.")
elif _allow_kylinsign == True and _verify_kylinsign == True: #策略: 警告
logging.debug("unknown sources apply installation policies: warning")
elif _allow_kylinsign == False and _verify_kylinsign == False: #策略: 关闭
logging.debug("unknown sources apply installation policies: close")
else:
logging.warning("Unknown sources apply installation policies get failed.")
#用户鉴权
details = {'polkit.message':details}
cancel_id = ''
action = "cn.kylinos.KylinSystemUpdater.action"

View File

@ -428,9 +428,9 @@ class UpdateManager():
logging.error(str(e))
# 进行本地deb包安装的操作
# _check_local_dep : 是否查询本地依赖
# _auto_satisfy : 是否通过网络下载依赖
def start_deb_install(self, deb_path = "", _check_local_dep = False, _auto_satisfy = False, source = '', sender=None):
# _check_local_dep : 是否查询本地依赖
# _auto_satisfy : 是否通过网络下载依赖
header = ''
desc = ''
absolute_path, debname = os.path.split(deb_path)

View File

@ -2757,4 +2757,7 @@ msgid "kylin-unattended-upgrade"
msgstr "自动更新"
msgid "Please check the system time and synchronize the system time before updating."
msgstr "请检查系统时间,同步系统时间后再进行更新。"
msgstr "请检查系统时间,同步系统时间后再进行更新。"
msgid "The package is unsigned, refuses to install."
msgstr "软件包未签名,拒绝安装。"

View File

@ -2690,4 +2690,7 @@ msgid "kylin-unattended-upgrade"
msgstr "自動更新"
msgid "Please check the system time and synchronize the system time before updating."
msgstr "請檢查系統時間,同步系統時間后再進行更新。"
msgstr "請檢查系統時間,同步系統時間后再進行更新。"
msgid "The package is unsigned, refuses to install."
msgstr "軟體包未簽名,拒絕安裝。"

View File

@ -2722,4 +2722,7 @@ msgid "kylin-unattended-upgrade"
msgstr "自動更新"
msgid "Please check the system time and synchronize the system time before updating."
msgstr "請檢查系統時間,同步系統時間后再進行更新。"
msgstr "請檢查系統時間,同步系統時間后再進行更新。"
msgid "The package is unsigned, refuses to install."
msgstr "軟體包未簽名,拒絕安裝。"