add method: InsertUpgradeHistory
This commit is contained in:
parent
b76acea3da
commit
fe55a422e4
|
@ -9,6 +9,7 @@ import sqlite3
|
|||
import logging
|
||||
import datetime
|
||||
from gettext import gettext as _
|
||||
from sys import exec_prefix
|
||||
from SystemUpdater.Core.DataAcquisition import PHPSeverSend
|
||||
from SystemUpdater.Core.UpdaterConfigParser import UpgradeConfig
|
||||
|
||||
|
@ -522,11 +523,40 @@ class Sqlite3Server(object):
|
|||
logging.error(_("Failed to initialize the database: %s"), str(e))
|
||||
return ''
|
||||
|
||||
def insert_upgrade_history(self, caller):
|
||||
caller_list = ['kylin-unattended-upgrade']
|
||||
def insert_upgrade_history(self, args, caller):
|
||||
caller_list = ['kylin-unattended-upgrade', "d-feet"]
|
||||
if caller not in caller_list:
|
||||
logging.warninng()
|
||||
logging.warning("Caller \" %s \": Operation without permission...", caller)
|
||||
return False
|
||||
# {"appname":GLib.Variant("s", "kylin-system-updater"), "version":GLib.Variant("s", "0.0")}
|
||||
# "description":GLib.Variant("s", "Update Manager for Kylin"), "date":GLib.Variant("s", "2022-07-27 15:23:51")
|
||||
# "status":GLib.Variant("s", "failed"), "keyword":GLib.Variant("s", "1")
|
||||
# "errorcode":GLib.Variant("s", "System upgrade is complete. "), "appname_cn":GLib.Variant("s", "音乐")
|
||||
upgrade_info = {}
|
||||
try:
|
||||
for it in args:
|
||||
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() :
|
||||
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"] )
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
return False
|
||||
return True
|
||||
|
||||
def listtojsonstr(lists):
|
||||
import json
|
||||
|
|
|
@ -1071,16 +1071,21 @@ class UpdateManagerDbusControllerUtils(dbus.service.Object):
|
|||
return pkglist
|
||||
|
||||
# 提供插入更新历史的接口
|
||||
@dbus.service.method(UPDATER_DBUS_INTERFACE, in_signature='', out_signature='', sender_keyword='sender')
|
||||
def InsertUpgradeHistory(self, sender=None):
|
||||
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' InsertUpgradeHistory Parsed silent upgrade ...')
|
||||
@dbus.service.method(UPDATER_DBUS_INTERFACE, in_signature='a{sv}', out_signature='b', sender_keyword='sender')
|
||||
def InsertUpgradeHistory(self, arg = {}, sender=None):
|
||||
try:
|
||||
# {"appname":GLib.Variant("s", "kylin-system-updater"), "version":GLib.Variant("s", "string value")}
|
||||
# "description":GLib.Variant("s", "Update Manager for Kylin"), "date":GLib.Variant("s", "2022-07-27 15:23:51")
|
||||
# "status":GLib.Variant("s", "failed"), "keyword":GLib.Variant("s", "1")
|
||||
# "errorcode":GLib.Variant("s", "System upgrade is complete. "), "appname_cn":GLib.Variant("s", "音乐")
|
||||
sender_name = get_proc_from_dbus_name(sender)
|
||||
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' Call InsertUpgradeHistory from %s.', sender_name)
|
||||
self.parent.sqlite3_server.insert_upgrade_history(sender_name)
|
||||
pass
|
||||
if not self.parent.sqlite3_server.insert_upgrade_history(arg, sender_name) :
|
||||
return False
|
||||
except Exception as e:
|
||||
logging.error("InsertUpgradeHistory Failed: %s" % str(e), exc_info=True)
|
||||
return False
|
||||
return True
|
||||
|
||||
WRITABLE_PROPERTIES = ()
|
||||
|
||||
|
|
Loading…
Reference in New Issue